diff options
author | Lukas Reschke <lukas@owncloud.com> | 2014-09-09 11:31:50 +0200 |
---|---|---|
committer | Lukas Reschke <lukas@owncloud.com> | 2014-09-09 11:31:50 +0200 |
commit | 353155b516e862d71de4effc7c1a1cf61c289b57 (patch) | |
tree | 958f4e1e638cc62b8deae5873a95ba9ea31df885 /lib/private/db | |
parent | ed2414fd0d983bd8e4682ded9c5b0c1b78c9fc97 (diff) | |
parent | c4fa07d7cfa06073e8c59ad7641a4221a844254c (diff) | |
download | nextcloud-server-353155b516e862d71de4effc7c1a1cf61c289b57.tar.gz nextcloud-server-353155b516e862d71de4effc7c1a1cf61c289b57.zip |
Merge pull request #7323 from owncloud/Jonny007-MKD-master
Update adapter.php
Diffstat (limited to 'lib/private/db')
-rw-r--r-- | lib/private/db/adapter.php | 11 | ||||
-rw-r--r-- | lib/private/db/adaptersqlite.php | 14 |
2 files changed, 19 insertions, 6 deletions
diff --git a/lib/private/db/adapter.php b/lib/private/db/adapter.php index 975b9432286..6742ccdbb45 100644 --- a/lib/private/db/adapter.php +++ b/lib/private/db/adapter.php @@ -51,13 +51,18 @@ class Adapter { . str_repeat('?,', count($input)-1).'? ' // Is there a prettier alternative? . 'FROM `' . $table . '` WHERE '; + $inserts = array_values($input); foreach($input as $key => $value) { - $query .= '`' . $key . '` = ? AND '; + $query .= '`' . $key . '`'; + if (is_null($value)) { + $query .= ' IS NULL AND '; + } else { + $inserts[] = $value; + $query .= ' = ? AND '; + } } $query = substr($query, 0, strlen($query) - 5); $query .= ' HAVING COUNT(*) = 0'; - $inserts = array_values($input); - $inserts = array_merge($inserts, $inserts); try { return $this->conn->executeUpdate($query, $inserts); diff --git a/lib/private/db/adaptersqlite.php b/lib/private/db/adaptersqlite.php index fa6d308ae32..5b9c5a437da 100644 --- a/lib/private/db/adaptersqlite.php +++ b/lib/private/db/adaptersqlite.php @@ -21,13 +21,21 @@ class AdapterSqlite extends Adapter { // NOTE: For SQLite we have to use this clumsy approach // otherwise all fieldnames used must have a unique key. $query = 'SELECT COUNT(*) FROM `' . $table . '` WHERE '; - foreach($input as $key => $value) { - $query .= '`' . $key . '` = ? AND '; + $inserts = array(); + foreach ($input as $key => $value) { + $query .= '`' . $key . '`'; + if (is_null($value)) { + $query .= ' IS NULL AND '; + } else { + $inserts[] = $value; + $query .= ' = ? AND '; + } } $query = substr($query, 0, strlen($query) - 5); + try { $stmt = $this->conn->prepare($query); - $result = $stmt->execute(array_values($input)); + $result = $stmt->execute($inserts); } catch(\Doctrine\DBAL\DBALException $e) { $entry = 'DB Error: "'.$e->getMessage() . '"<br />'; $entry .= 'Offending command was: ' . $query . '<br />'; |