diff options
author | Jonny007-MKD <1-23-4-5@web.de> | 2013-08-23 16:30:41 +0200 |
---|---|---|
committer | Jörn Friedrich Dreyer <jfd@butonic.de> | 2014-07-01 17:47:27 +0200 |
commit | 4161fd24083a5f12033805ff3d262b8a51780650 (patch) | |
tree | cdd485757639b5e124a44d72748b6db17183e054 /lib/private/db | |
parent | 19a6dc5420d3a27c50590b2f060700edff2ef73e (diff) | |
download | nextcloud-server-4161fd24083a5f12033805ff3d262b8a51780650.tar.gz nextcloud-server-4161fd24083a5f12033805ff3d262b8a51780650.zip |
Update adapter.php
Modified insertIfNotExist() to support NULL values
Diffstat (limited to 'lib/private/db')
-rw-r--r-- | lib/private/db/adapter.php | 11 |
1 files changed, 8 insertions, 3 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); |