Beispiel #1
0
 /**
  * sets a value in the appconfig
  *
  * @param string $app app
  * @param string $key key
  * @param string $value value
  *
  * Sets a value. If the key did not exist before it will be created.
  */
 public function setValue($app, $key, $value)
 {
     // Does the key exist? no: insert, yes: update.
     if (!$this->hasKey($app, $key)) {
         $data = array('appid' => $app, 'configkey' => $key, 'configvalue' => $value);
         $this->conn->insert('*PREFIX*appconfig', $data);
     } else {
         $oldValue = $this->getValue($app, $key);
         if ($oldValue === strval($value)) {
             return true;
         }
         $data = array('configvalue' => $value);
         $where = array('appid' => $app, 'configkey' => $key);
         $this->conn->update('*PREFIX*appconfig', $data, $where);
     }
     if (!isset($this->cache[$app])) {
         $this->cache[$app] = array();
     }
     if (is_array($this->apps) and array_search($app, $this->apps) === false) {
         $this->apps[$app] = $app;
     }
     $this->cache[$app][$key] = $value;
 }