本文整理汇总了PHP中Doctrine_Record::postUpdate方法的典型用法代码示例。如果您正苦于以下问题:PHP Doctrine_Record::postUpdate方法的具体用法?PHP Doctrine_Record::postUpdate怎么用?PHP Doctrine_Record::postUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine_Record
的用法示例。
在下文中一共展示了Doctrine_Record::postUpdate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
/**
* update
* updates the given record
*
* @param Doctrine_Record $record record to be updated
* @return boolean whether or not the update was successful
*/
public function update(Doctrine_Record $record)
{
$event = new Doctrine_Event($this, Doctrine_Event::RECORD_UPDATE);
$record->preUpdate($event);
if (!$event->skipOperation) {
$array = $record->getPrepared();
if (empty($array)) {
return false;
}
$set = array();
foreach ($array as $name => $value) {
if ($value instanceof Doctrine_Expression) {
$set[] = $value->getSql();
unset($array[$name]);
} else {
$set[] = $name . ' = ?';
if ($value instanceof Doctrine_Record) {
if (!$value->exists()) {
$record->save($this->conn);
}
$array[$name] = $value->getIncremented();
$record->set($name, $value->getIncremented());
}
}
}
$params = array_values($array);
$id = $record->identifier();
if (!is_array($id)) {
$id = array($id);
}
$id = array_values($id);
$params = array_merge($params, $id);
$sql = 'UPDATE ' . $this->conn->quoteIdentifier($record->getTable()->getTableName()) . ' SET ' . implode(', ', $set) . ' WHERE ' . implode(' = ? AND ', $record->getTable()->getPrimaryKeys()) . ' = ?';
$stmt = $this->conn->getDbh()->prepare($sql);
$stmt->execute($params);
$record->assignIdentifier(true);
}
$record->postUpdate($event);
return true;
}