public function existsBy($predicate, $combination = Predicate\PredicateSet::OP_AND)
    {
        try {
            $select = $this->select()->where($predicate, $combination)
                    ->columns(['count' => new Expression('count(*)')]);
            $result = $select->execute()
                             ->toArray();
        } catch (\Exception $e) {
            throw new Exception\InvalidArgumentException(__METHOD__ . ": invaid usage ({$e->getMessage()})");
        }

        return ($result[0]['count'] > 0);
    }
public function existsBy($predicate, $combination = Predicate\PredicateSet::OP_AND)
    {
        try {
            $select = $this->select()->where($predicate, $combination)
                    ->columns(['count' => new Expression('count(*)')]);
            $result = $select->execute()
                             ->toArray();
        } catch (\Exception $e) {
            throw new Exception\InvalidArgumentException(__METHOD__ . ": invaid usage ({$e->getMessage()})");
        }

        return ($result[0]['count'] > 0);
    }
public function existsBy ( $ predicate , $ combination = Predicate \ PredicateSet :: OP_AND ) { try { $ select = $ this -> select ( ) -> where ( $ predicate , $ combination ) -> columns ( [ 'count' => new Expression ( 'count(*)' ) ] ) ; $ result = $ select -> execute ( ) -> toArray ( ) ; } catch ( \ Exception $ e ) { throw new Exception \ InvalidArgumentException ( __METHOD__ . ": invaid usage ({$e->getMessage()})" ) ; } return ( $ result [ 0 ] [ 'count' ] > 0 ) ; }
Test if a record exists by a predicate

@param  Where|\Closure|string|array|Predicate\PredicateInterface $predicate
@param  string $combination One of the OP_* constants from Predicate\PredicateSet

@throws Exception\InvalidArgumentException when the predicate is not correct

@return boolean
Test if a record exists by a predicate