Fixed bug on columns not being quoted on INSERT statements, reported by email by Gavin Mogan
This commit is contained in:
parent
d47b8f11ec
commit
777539fbf3
@ -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);
|
||||
$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) {
|
||||
$a[] = $value->getSql();
|
||||
unset($values[$k]);
|
||||
} else {
|
||||
$a[] = '?';
|
||||
}
|
||||
}
|
||||
|
||||
// build the statement
|
||||
$query = 'INSERT INTO ' . $this->quoteIdentifier($table)
|
||||
. ' (' . implode(', ', $cols) . ') '
|
||||
. 'VALUES (';
|
||||
|
||||
$a = array();
|
||||
foreach ($values as $k => $value) {
|
||||
if ($value instanceof Doctrine_Expression) {
|
||||
$value = $value->getSql();
|
||||
unset($values[$k]);
|
||||
} else {
|
||||
$value = '?';
|
||||
}
|
||||
$a[] = $value;
|
||||
|
||||
}
|
||||
$query .= implode(', ', $a) . ')';
|
||||
// prepare and execute the statement
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user