Cake\ORM\Table::exists PHP Method

exists() public method

{@inheritDoc}
public exists ( $conditions )
    public function exists($conditions)
    {
        return (bool) count($this->find('all')->select(['existing' => 1])->where($conditions)->limit(1)->hydrate(false)->toArray());
    }

Usage Example

 public function exists($conditions, $checkStatus = false)
 {
     if (!is_array($conditions) && is_numeric($conditions)) {
         $conditions = ['id' => $conditions];
     }
     if ($checkStatus && !empty($this->_activeStatuses)) {
         $conditions['status IN '] = $this->_activeStatuses;
     }
     return parent::exists($conditions);
 }
All Usage Examples Of Cake\ORM\Table::exists