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
{
$this->connect();
if ( ! is_int(key($types))) {
$types = $this->extractTypeValues($data, $types);
if (empty($data)) {
return $this->executeUpdate('INSERT INTO ' . $tableName . ' ()' . ' VALUES ()');
}
$query = 'INSERT INTO ' . $tableName
. ' (' . implode(', ', array_keys($data)) . ')'
. ' VALUES (' . implode(', ', array_fill(0, count($data), '?')) . ')';
return $this->executeUpdate($query, array_values($data), $types);
return $this->executeUpdate(
'INSERT INTO ' . $tableName . ' (' . implode(', ', array_keys($data)) . ')' .
' VALUES (' . implode(', ', array_fill(0, count($data), '?')) . ')',
array_values($data),
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