public static function set($key, $value) { if (!User::isLoggedIn()) { throw new Exception("User is not logged in."); } $id = User::getUserID(); self::$userConfig = null; if (is_null($value) || is_string($value) && strlen(trim($value)) == 0) { // Just remove the row and let the defaults take over return Db::execute("delete from zz_users_config where id = :id and locker = :key", array(":id" => $id, ":key" => $key)); } $value = json_encode($value); return Db::execute("insert into zz_users_config (id, locker, content) values (:id, :key, :value)\n on duplicate key update content = :value", array(":id" => $id, ":key" => $key, ":value" => $value)); }