Commit 777539fb authored by jackbravo's avatar jackbravo

Fixed bug on columns not being quoted on INSERT statements, reported by email by Gavin Mogan

parent d47b8f11
......@@ -468,25 +468,26 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
if (empty($values)) {
return false;
}
// column names are specified as array keys
$cols = array_keys($values);
// build the statement
$query = 'INSERT INTO ' . $this->quoteIdentifier($table)
. ' (' . implode(', ', $cols) . ') '
. 'VALUES (';
// column names are specified as array keys
$cols = array();
// the query VALUES will contain either expresions (eg 'NOW()') or ?
$a = array();
foreach ($values as $k => $value) {
$cols[] = $this->quoteIdentifier($k);
if ($value instanceof Doctrine_Expression) {
$value = $value->getSql();
$a[] = $value->getSql();
unset($values[$k]);
} else {
$value = '?';
$a[] = '?';
}
$a[] = $value;
}
// build the statement
$query = 'INSERT INTO ' . $this->quoteIdentifier($table)
. ' (' . implode(', ', $cols) . ') '
. 'VALUES (';
$query .= implode(', ', $a) . ')';
// prepare and execute the statement
......
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