Cake\ORM\Table::deleteAll PHP Method

deleteAll() public method

{@inheritDoc}
public deleteAll ( $conditions )
    public function deleteAll($conditions)
    {
        $query = $this->query()->delete()->where($conditions);
        $statement = $query->execute();
        $statement->closeCursor();
        return $statement->rowCount();
    }

Usage Example

Example #1
0
 /**
  * Also deletes the nodes in the subtree of the entity to be delete
  *
  * @param \Cake\Event\Event the beforeDelete event that was fired
  * @param \Cake\ORM\Entity the entity that is going to be saved
  * @return void
  */
 public function beforeDelete(Event $event, Entity $entity)
 {
     $config = $this->config();
     $this->_ensureFields($entity);
     $left = $entity->get($config['left']);
     $right = $entity->get($config['right']);
     $diff = $right - $left + 1;
     if ($diff > 2) {
         $this->_table->deleteAll(["{$config['left']} >=" => $left + 1, "{$config['left']} <=" => $right - 1]);
     }
     $this->_sync($diff, '-', "> {$right}");
 }
All Usage Examples Of Cake\ORM\Table::deleteAll