diff options
author | Joas Schilling <nickvergessen@owncloud.com> | 2015-03-09 17:25:02 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-03-09 22:37:49 +0100 |
commit | 8fa692388b29979c56ff6d0229d20e09e8ecba65 (patch) | |
tree | e3d0e47582c55aa0b4f29ef935396a7747684dac /lib/private/allconfig.php | |
parent | 94b7fa17c55ed5c194b506ca6ab426fa38119b3c (diff) | |
download | nextcloud-server-8fa692388b29979c56ff6d0229d20e09e8ecba65.tar.gz nextcloud-server-8fa692388b29979c56ff6d0229d20e09e8ecba65.zip |
Allow specifying the compare-array for insertIfNotExists()
Diffstat (limited to 'lib/private/allconfig.php')
-rw-r--r-- | lib/private/allconfig.php | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/private/allconfig.php b/lib/private/allconfig.php index 00defd920d7..b8bba7986e6 100644 --- a/lib/private/allconfig.php +++ b/lib/private/allconfig.php @@ -189,11 +189,18 @@ class AllConfig implements \OCP\IConfig { return; } - $data = array($value, $userId, $appName, $key); + $affectedRows = 0; if (!$exists && $preCondition === null) { - $sql = 'INSERT INTO `*PREFIX*preferences` (`configvalue`, `userid`, `appid`, `configkey`)'. - 'VALUES (?, ?, ?, ?)'; + $this->connection->insertIfNotExist('*PREFIX*preferences', [ + 'configvalue' => $value, + 'userid' => $userId, + 'appid' => $appName, + 'configkey' => $key, + ], ['configvalue', 'userid', 'appid']); + $affectedRows = 1; } elseif ($exists) { + $data = array($value, $userId, $appName, $key); + $sql = 'UPDATE `*PREFIX*preferences` SET `configvalue` = ? '. 'WHERE `userid` = ? AND `appid` = ? AND `configkey` = ? '; @@ -206,8 +213,8 @@ class AllConfig implements \OCP\IConfig { } $data[] = $preCondition; } + $affectedRows = $this->connection->executeUpdate($sql, $data); } - $affectedRows = $this->connection->executeUpdate($sql, $data); // only add to the cache if we already loaded data for the user if ($affectedRows > 0 && isset($this->userCache[$userId])) { |