Controller_Data::delete PHP Метод

delete() абстрактный публичный Метод

Locate and remove record in the storade with specified $id. Return true if record was deleted or false if it wasn't found. In most cases, the record data will first be loaded and then deleted, just to make sure the record is accessible with specified conditions, so you can silently ignore error.
abstract public delete ( $model, $id )
    public abstract function delete($model, $id);

Usage Example

Пример #1
0
 /**
  * Delete a record. If the model is loaded, delete the current id.
  * If not loaded, load model through the $id parameter and delete.
  */
 public function delete($id = null)
 {
     if ($this->loaded() && !is_null($id) && $id !== $this->id) {
         throw $this->exception('Unable to determine which record to delete');
     }
     if (!is_null($id) && (!$this->loaded() || $this->loaded() && $id !== $this->id)) {
         $this->load($id);
     }
     if (!$this->loaded()) {
         throw $this->exception('Unable to determine which record to delete');
     }
     $id = $this->id;
     $this->hook('beforeDelete', array($id));
     $this->controller->delete($this, $id);
     $this->hook('afterDelete', array($id));
     $this->unload();
     return $this;
 }