public function count($field = '*')
    {
        if ($field !== '*' && !in_array($field, $this->getFields())) {
            throw new \DomainException(__METHOD__ . '|Field is not allowed ! (field: ' . $field . ')');
        }

        $query = 'SELECT COUNT(' . $field . ') AS NB_RESULTS FROM ' . $this->table . ' ' . $this->getQueryWhere();

        $statement = $this->db->prepare($query);
        $statement->execute($this->binds);

        $this->clear();

        return (int) $statement->fetchColumn(0);
    }
public function count($field = '*')
    {
        if ($field !== '*' && !in_array($field, $this->getFields())) {
            throw new \DomainException(__METHOD__ . '|Field is not allowed ! (field: ' . $field . ')');
        }

        $query = 'SELECT COUNT(' . $field . ') AS NB_RESULTS FROM ' . $this->table . ' ' . $this->getQueryWhere();

        $statement = $this->db->prepare($query);
        $statement->execute($this->binds);

        $this->clear();

        return (int) $statement->fetchColumn(0);
    }
public function count ( $ field = '*' ) { if ( $ field !== '*' && ! in_array ( $ field , $ this -> getFields ( ) ) ) { throw new \ DomainException ( __METHOD__ . '|Field is not allowed ! (field: ' . $ field . ')' ) ; } $ query = 'SELECT COUNT(' . $ field . ') AS NB_RESULTS FROM ' . $ this -> table . ' ' . $ this -> getQueryWhere ( ) ; $ statement = $ this -> db -> prepare ( $ query ) ; $ statement -> execute ( $ this -> binds ) ; $ this -> clear ( ) ; return ( int ) $ statement -> fetchColumn ( 0 ) ; }
Count number of results for query.

@param string $field
@return integer
@throws \DomainException
Count number of results for query .