1
0
mirror of synced 2024-12-14 15:16:04 +03:00

fixed identifier quoting for update()

This commit is contained in:
zYne 2007-04-18 09:49:54 +00:00
parent 9862f45fc3
commit 26a723e81d

View File

@ -259,19 +259,19 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implemen
} }
$set = array(); $set = array();
foreach ($array as $name => $value) { foreach ($array as $name => $value) {
$set[] = $name." = ?"; $set[] = $name . ' = ?';
if ($value instanceof Doctrine_Record) { if ($value instanceof Doctrine_Record) {
switch ($value->state()) { switch ($value->state()) {
case Doctrine_Record::STATE_TCLEAN: case Doctrine_Record::STATE_TCLEAN:
case Doctrine_Record::STATE_TDIRTY: case Doctrine_Record::STATE_TDIRTY:
$record->save($this->conn); $record->save($this->conn);
default: default:
$array[$name] = $value->getIncremented(); $array[$name] = $value->getIncremented();
$record->set($name, $value->getIncremented()); $record->set($name, $value->getIncremented());
};
} }
}; }
}
$params = array_values($array); $params = array_values($array);
$id = $record->obtainIdentifier(); $id = $record->obtainIdentifier();
@ -282,7 +282,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implemen
$id = array_values($id); $id = array_values($id);
$params = array_merge($params, $id); $params = array_merge($params, $id);
$sql = 'UPDATE ' . $record->getTable()->getTableName() $sql = 'UPDATE ' . $this->conn->quoteIdentifier($record->getTable()->getTableName())
. ' SET ' . implode(', ', $set) . ' SET ' . implode(', ', $set)
. ' WHERE ' . implode(' = ? AND ', $record->getTable()->getPrimaryKeys()) . ' WHERE ' . implode(' = ? AND ', $record->getTable()->getPrimaryKeys())
. ' = ?'; . ' = ?';