Commit 6f898417 authored by Steve Müller's avatar Steve Müller Committed by Benjamin Eberlei

fix insert with empty data given

parent 4ce45f76
...@@ -548,15 +548,16 @@ class Connection implements DriverConnection ...@@ -548,15 +548,16 @@ class Connection implements DriverConnection
{ {
$this->connect(); $this->connect();
if ( ! is_int(key($types))) { if (empty($data)) {
$types = $this->extractTypeValues($data, $types); return $this->executeUpdate('INSERT INTO ' . $tableName . ' ()' . ' VALUES ()');
} }
$query = 'INSERT INTO ' . $tableName return $this->executeUpdate(
. ' (' . implode(', ', array_keys($data)) . ')' 'INSERT INTO ' . $tableName . ' (' . implode(', ', array_keys($data)) . ')' .
. ' VALUES (' . implode(', ', array_fill(0, count($data), '?')) . ')'; ' VALUES (' . implode(', ', array_fill(0, count($data), '?')) . ')',
array_values($data),
return $this->executeUpdate($query, array_values($data), $types); is_int(key($types)) ? $types : $this->extractTypeValues($data, $types)
);
} }
/** /**
......
Markdown is supported
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