Also update sqliteadapter
This commit is contained in:
parent
b20018928d
commit
c4fa07d7cf
|
@ -21,13 +21,21 @@ class AdapterSqlite extends Adapter {
|
||||||
// NOTE: For SQLite we have to use this clumsy approach
|
// NOTE: For SQLite we have to use this clumsy approach
|
||||||
// otherwise all fieldnames used must have a unique key.
|
// otherwise all fieldnames used must have a unique key.
|
||||||
$query = 'SELECT COUNT(*) FROM `' . $table . '` WHERE ';
|
$query = 'SELECT COUNT(*) FROM `' . $table . '` WHERE ';
|
||||||
|
$inserts = array();
|
||||||
foreach ($input as $key => $value) {
|
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 = substr($query, 0, strlen($query) - 5);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$stmt = $this->conn->prepare($query);
|
$stmt = $this->conn->prepare($query);
|
||||||
$result = $stmt->execute(array_values($input));
|
$result = $stmt->execute($inserts);
|
||||||
} catch(\Doctrine\DBAL\DBALException $e) {
|
} catch(\Doctrine\DBAL\DBALException $e) {
|
||||||
$entry = 'DB Error: "'.$e->getMessage() . '"<br />';
|
$entry = 'DB Error: "'.$e->getMessage() . '"<br />';
|
||||||
$entry .= 'Offending command was: ' . $query . '<br />';
|
$entry .= 'Offending command was: ' . $query . '<br />';
|
||||||
|
|
Loading…
Reference in New Issue