Commit 5dd0adfe authored by Guilherme Blanco's avatar Guilherme Blanco

Merge pull request #314 from deeky666/microoptimize-connection-insert

Remove unnecessary code from Connection::insert
parents 38f67937 5b86fad8
......@@ -533,22 +533,13 @@ class Connection implements DriverConnection
{
$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))) {
$types = $this->extractTypeValues($data, $types);
}
$query = 'INSERT INTO ' . $tableName
. ' (' . implode(', ', $cols) . ')'
. ' VALUES (' . implode(', ', $placeholders) . ')';
. ' (' . implode(', ', array_keys($data)) . ')'
. ' VALUES (' . implode(', ', array_fill(0, count($data), '?')) . ')';
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