Doctrine_Record::postUpdate PHP Méthode

postUpdate() public méthode

Empty template method to provide concrete Record classes with the possibility to hook into the saving procedure only when the record is going to be updated.
public postUpdate ( $event )
    public function postUpdate($event)
    {
    }

Usage Example

 /**
  * 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;
 }