Commit 4161fd24 authored by Jonny007-MKD's avatar Jonny007-MKD Committed by Jörn Friedrich Dreyer
Browse files

Update adapter.php

Modified insertIfNotExist() to support NULL values
parent 19a6dc54
......@@ -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);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment