Esempio n. 1
0
 /**
  * Save a preference.
  * 
  * @param Database §db
  * @param Preference $p
  */
 public function savePreference(Database $db, Preference $p)
 {
     $oldValue = $this->getPreferenceValue($p->getKey());
     if (is_null($oldValue)) {
         $db->query("\n\t\t\t\t\tINSERT INTO " . TABLE_PLUGINS_SETTINGS . "\n\t\t\t\t\t(package, `key`, value)\n\t\t\t\t\tVALUES\n\t\t\t\t\t(?, ?, ?)\n\t\t\t\t", array($this->package, $p->getKey(), $p->getValue()));
     } else {
         $db->query("\n\t\t\t\t\tUPDATE " . TABLE_PLUGINS_SETTINGS . "\n\t\t\t\t\tSET value = ?\n\t\t\t\t\tWHERE `key` = ? AND package = ?\n\t\t\t\t", array(is_null($p->getValue()) ? $p->getDefaultValue() : $p->getValue(), $p->getKey(), $this->package));
     }
 }