Commit 5b86fad8 authored by Steve Müller's avatar Steve Müller

remove unnecessary code from Connection::insert

parent cb20a390
...@@ -533,22 +533,13 @@ class Connection implements DriverConnection ...@@ -533,22 +533,13 @@ class Connection implements DriverConnection
{ {
$this->connect(); $this->connect();
// column names are specified as array keys
$cols = array();
$placeholders = array();
foreach ($data as $columnName => $value) {
$cols[] = $columnName;
$placeholders[] = '?';
}
if ( ! is_int(key($types))) { if ( ! is_int(key($types))) {
$types = $this->extractTypeValues($data, $types); $types = $this->extractTypeValues($data, $types);
} }
$query = 'INSERT INTO ' . $tableName $query = 'INSERT INTO ' . $tableName
. ' (' . implode(', ', $cols) . ')' . ' (' . implode(', ', array_keys($data)) . ')'
. ' VALUES (' . implode(', ', $placeholders) . ')'; . ' VALUES (' . implode(', ', array_fill(0, count($data), '?')) . ')';
return $this->executeUpdate($query, array_values($data), $types); return $this->executeUpdate($query, array_values($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