From: Nicolas LÅ“uillet Date: Sat, 21 Sep 2013 12:37:53 +0000 (+0200) Subject: bug fix #229: theme not stored on updated poches X-Git-Tag: 1.0.0~19 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=58ace4941ef3ec92ab71ae84df816343e2deb625;p=github%2Fwallabag%2Fwallabag.git bug fix #229: theme not stored on updated poches --- diff --git a/inc/poche/Database.class.php b/inc/poche/Database.class.php index 4d664992..0662581b 100644 --- a/inc/poche/Database.class.php +++ b/inc/poche/Database.class.php @@ -113,9 +113,17 @@ class Database { } public function updateUserConfig($userId, $key, $value) { - $sql_update = "UPDATE users_config SET `value`=? WHERE `user_id`=? AND `name`=?"; - $params_update = array($value, $userId, $key); - $query = $this->executeQuery($sql_update, $params_update); + $config = $this->getConfigUser($userId); + + if (!isset ($user_config[$key])) { + $sql = "INSERT INTO users_config (`value`, `user_id`, `name`) VALUES (?, ?, ?)"; + } + else { + $sql = "UPDATE users_config SET `value`=? WHERE `user_id`=? AND `name`=?"; + } + + $params = array($value, $userId, $key); + $query = $this->executeQuery($sql, $params); } private function executeQuery($sql, $params) {