From: Evan Prodromou Date: Sun, 8 Nov 2009 04:16:59 +0000 (-0500) Subject: pkeyGet() and save() methods for Config X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=408510f527be0a1a22fa564369fad48938b7bd02;p=quix0rs-gnu-social.git pkeyGet() and save() methods for Config --- diff --git a/classes/Config.php b/classes/Config.php index 92f237d7f2..390d75381a 100644 --- a/classes/Config.php +++ b/classes/Config.php @@ -120,6 +120,35 @@ class Config extends Memcached_DataObject return $result; } + function &pkeyGet($kv) + { + return Memcached_DataObject::pkeyGet('Config', $kv); + } + + static function save($section, $setting, $value) + { + $result = null; + + $config = Config::pkeyGet(array('section' => $section, + 'setting' => $setting)); + + if (!empty($config)) { + $orig = clone($config); + $config->value = $value; + $result = $config->update($orig); + } else { + $config = new Config(); + + $config->section = $section; + $config->setting = $setting; + $config->value = $value; + + $result = $config->insert(); + } + + return $result; + } + function _blowSettingsCache() { $c = self::memcache();