summaryrefslogtreecommitdiffstats
path: root/lib/private/allconfig.php
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@owncloud.com>2015-03-09 17:25:02 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2015-03-09 22:37:49 +0100
commit8fa692388b29979c56ff6d0229d20e09e8ecba65 (patch)
treee3d0e47582c55aa0b4f29ef935396a7747684dac /lib/private/allconfig.php
parent94b7fa17c55ed5c194b506ca6ab426fa38119b3c (diff)
downloadnextcloud-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.php15
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])) {