Performs and returns the COUNT(*) for the query.

@return int
175309
protected function _performCount()
    {
        $query = $this->cleanCopy();
        $counter = $this->_counter;
        if ($counter) {
            $query->counter(null);

            return (int)$counter($query);
        }

        $complex = (
            $query->clause('distinct') ||
            count($query->clause('group')) ||
            count($query->clause('union')) ||
            $query->clause('having')
        );

        if (!$complex) {
            // Expression fields could have bound parameters.
            foreach ($query->clause('select') as $field) {
                if ($field instanceof ExpressionInterface) {
                    $complex = true;
                    break;
                }
            }
        }

        if (!$complex && $this->_valueBinder !== null) {
            $order = $this->clause('order');
            $complex = $order === null ? false : $order->hasNestedExpression();
        }

        $count = ['count' => $query->func()->count('*')];

        if (!$complex) {
            $query->getEagerLoader()->enableAutoFields(false);
            $statement = $query
                ->select($count, true)
                ->enableAutoFields(false)
                ->execute();
        } else {
            $statement = $this->getConnection()->newQuery()
                ->select($count)
                ->from(['count_source' => $query])
                ->execute();
        }

        $result = $statement->fetch('assoc')['count'];
        $statement->closeCursor();

        return (int)$result;
    }
85192
public function count()
    {
        $myQuery = clone $this->query;

        if (!Str::contains(Str::lower($myQuery->toSql()), ['union', 'having', 'distinct', 'order by', 'group by'])) {
            $row_count = $this->connection->getQueryGrammar()->wrap('row_count');
            $myQuery->select($this->connection->raw("'1' as {$row_count}"));
        }
        return $this->connection->table($this->connection->raw('(' . $myQuery->toSql() . ') count_row_table'))
                        ->setBindings($myQuery->getBindings())->count();
    }
129729
public function count()
    {
        $query = clone $this;
        $query->select = 'count(*)';
        return (int)$query->execute()->fetch(PDO::FETCH_NUM)[0];
    }
860176
public function count()
    {
        if (!isset($this->count)) {
            $this->count = $this->repository->count($this->query);
        }
        return $this->count;
    }
1169406
public function count()
    {
        return $this->items !== null
            ? parent::count()
            : (int)current(
                static::db()->query(
                    (clone $this->selFromDbAllQuery())->count()
                )->fetch()
            );
    }
1352293
public function count()
    {
        if (null === $this->count) {
            try {
                $this->count = array_sum(array_map('current', $this->getCountQuery()->getScalarResult()));
            } catch (NoResultException $e) {
                $this->count = 0;
            }
        }

        return $this->count;
    }
309152
public function count()
    {
        if ($this->_resultsCount === null) {
            $this->_resultsCount = $this->_performCount();
        }

        return $this->_resultsCount;
    }
942458
private function getCountQuery()
    {
        /** @var Query $countQuery */
        $countQuery = $this->cloneQuery($this->query);

        if (! $countQuery->hasHint(CountWalker::HINT_DISTINCT)) {
            $countQuery->setHint(CountWalker::HINT_DISTINCT, true);
        }

        if ($this->useOutputWalker($countQuery)) {
            $platform = $countQuery->getEntityManager()->getConnection()->getDatabasePlatform(); // law of demeter win

            $rsm = new ResultSetMapping();

            $rsm->addScalarResult($platform->getSQLResultCasing('dctrn_count'), 'count', Type::getType('integer'));

            $countQuery->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, CountOutputWalker::class);
            $countQuery->setResultSetMapping($rsm);
        } else {
            $this->appendTreeWalker($countQuery, CountWalker::class);
            $this->unbindUnusedQueryParams($countQuery);
        }

        $countQuery->setFirstResult(null)->setMaxResults(null);

        return $countQuery;
    }
1126438
public function count(): ?int
    {
        // no where, count all simply
        $where = $this->query['where'] ?? null;
        if ($where == null) {
            return $this->agent->count($this->table);
        }

        $from = '';
        if ($this->query) {
            $isSub = $this->isSub;
            $this->isSub = true;
            $from = $this->toString();
            $this->isSub = $isSub; // restore
        }

        if ($from == '') {
            $from = "SELECT 1 FROM {$this->table} ". trim($this->toQueryString('where', false));
        }
        $from = trim($from);

        $query = "SELECT count(*) AS count FROM (\n\t{$from}\n) AS tmp";
        $result = $this->agent->get($query, null, 'object');

        return isset($result->count) ? intval($result->count) : null;
    }
1275448
function count()
    {
        if ( $this->count !== null )
            return $this->count;

        if ( $this->query === null )
        {
            $this->query = $this->generateSQL();
        }
        if ( $this->query === false )
            return 0;
        $query = "SELECT count(*) AS count {$this->query}";
        $db = eZDB::instance();
        $rows = $db->arrayQuery( $query );
        if ( count( $rows ) == 0 )
            $this->count = 0;
        else
            $this->count = $rows[0]['count'];
        return $this->count;
    }
84933
protected function paginationCount(): int
	{
		$clone = (clone $this)->clearOrderings();

		if(empty($this->groupings) && $this->distinct === false)
		{
			return $clone->count();
		}

		return $this->newInstance()->table(new Subquery($clone, 'count'))->count();
	}
105037
protected function countTotalRows()
    {
        $source = $this->getSource();
        /** @var \Doctrine\ORM\Query\Expr\Select $select */
        $source->resetDQLPart('select')->setFirstResult(0)->select('count(' . $this->entityAlias . ')');
        return (int)$source->getQuery()->getSingleScalarResult();
    }
1047018
public function count()
    {
        if (empty($this->queryString)) {
            $builder = clone $this->builder;
            $builder->resetQueryPart('orderBy');
            $stmt = $builder->execute();
        } else {
            $stmt = $this->connection->executeQuery($this->queryString, $this->queryParams);
        }

        return (int) $stmt->rowCount();
    }
137867
public function count()
    {
        $total = 0;
        $sql = clone($this);
        $sql->_fields = 'COUNT(*) AS total';
        foreach ($sql->getJoins() as $join) {
            $join->setFields(null);
        }
        $result = $this->_adapter->query($sql, $sql->getParameters());
        if (!empty($result)) {
            $total = intval($result[0]['total']);
        }
        return $total;
    }
913266
public function count()
    {
        $sql = "select count({$this->count_fields}) as c from {$this->table} {$this->join} {$this->where} {$this->union} {$this->group}";

        if ($this->if_union)
        {
            $sql = str_replace('{#union_select#}', "count({$this->count_fields}) as c", $sql);
            $c = $this->db->query($sql)->fetchall();
            $cc = 0;
            foreach ($c as $_c)
            {
                $cc += $_c['c'];
            }
            $count =  intval($cc);
        }
        else
        {
            $_c = $this->db->query($sql);
            if ($_c === false)
            {
                return false;
            }
            else
            {
                $c = $_c->fetch();
            }
            $count = intval($c['c']);
        }
        return $count;
    }
153677
public function count(): int
    {
        $collection = $this->documentManager->getCollection($this->documentClass);

        return $collection->count($this->query);
    }
1254770
public function count()
    {
        $select = clone $this->select;
        $select->reset(Select::COLUMNS);
        $select->columns([
            'c' => $this->raw('COUNT(*)')
        ]);
        
        $rows = $this->loadRecords($select);
        if (isset($rows[0]['c'])) {
            return (int)$rows[0]['c'];
        }
        
        return false;
    }