Counts all records matching this select query

@return int
356386
public function count()
    {
        $events = $this->_entity->getEventManager();
        $event = new SelectEvent(
            [
                'sqlQuery' => $this,
                'params' => [],
                'action' => SelectEvent::FIND_COUNT,
                'singleItem' => true
            ]
        );
        $events->trigger(SelectEvent::BEFORE_COUNT, $this->_entity, $event);
        $rows = parent::count();
        return $rows;
    }
309152
public function count()
    {
        if ($this->_resultsCount === null) {
            $this->_resultsCount = $this->_performCount();
        }

        return $this->_resultsCount;
    }
827829
public function count(): int
    {
        $this->flags['count'] = true;
        $pdoStatement = $this->provideStatement();
        $pdoStatement = $this->execute($pdoStatement);
        return $pdoStatement->fetchColumn();
    }
431514
public function count()
    {
        $this->countQuery->execute();
        $res = $this->countQuery->fetchColumn();
        $this->countQuery->closeCursor();
        return (int) $res;
    }
1019580
public function countAll($select = ['id'])
    {
        $total = $this->db->select($select)->from($this->table)->execute()->rowCount();
        $this->debug->debug(__FUNCTION__, 'Total Result: ' . $total);

        return $total;
    }
637942
public function count()
    {
        if ($this->_count !== null) {
            return $this->_count;
        }
        if ($this->_statement) {
            return $this->_count = $this->_statement->rowCount();
        }

        if ($this->_results instanceof SplFixedArray) {
            $this->_count = $this->_results->count();
        } else {
            $this->_count = count($this->_results);
        }

        return $this->_count;
    }
792227
public function count()
    {
        $query   = $this->query();
        $myQuery = $query instanceof EloquentBuilder ? clone $this->query() : $query;
        if ($query instanceof Collection) {
            return $query->count();
        }

        $finalQuery = $this->applyScopes($myQuery);
        $this->applyGlobalGroupScope($finalQuery);


        // if its a normal query ( no union, having and distinct word )
        // replace the select with static text to improve performance
        $connection = $finalQuery->getQuery()->getConnection();

        if (!Str::contains(Str::lower($finalQuery->toSql()), ['union', 'having', 'distinct', 'order by', 'group by'])) {

            $row_count = $connection->getQueryGrammar()->wrap('row_count');
            return $connection->table($connection->raw('(' . $finalQuery->toSql() . ') count_row_table'))->select($connection->raw("'1' as {$row_count}"))->setBindings($finalQuery->getBindings())->count();
        }

        return $connection->table($connection->raw('(' . $finalQuery->toSql() . ') count_row_table'))
                        ->setBindings($finalQuery->getBindings())->count();
    }
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;
    }
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;
    }
56952
public function count()
    {
        try {
            $originalQuery = $this->queryBuilder->getQuery();
            $dqlQuery = clone $originalQuery;
            $dqlQuery->setParameters($originalQuery->getParameters());
            $dqlQuery->setHint(\Doctrine\ORM\Query::HINT_CUSTOM_TREE_WALKERS, [CountWalker::class]);
            $offset = $dqlQuery->getFirstResult();
            $limit = $dqlQuery->getMaxResults();
            if ($offset !== null) {
                $dqlQuery->setFirstResult(null);
            }
            $numberOfResults = (int)$dqlQuery->getSingleScalarResult();
            if ($offset !== null) {
                $numberOfResults = max(0, $numberOfResults - $offset);
            }
            if ($limit !== null) {
                $numberOfResults = min($numberOfResults, $limit);
            }
            return $numberOfResults;
        } catch (\Doctrine\ORM\ORMException $ormException) {
            $message = $this->throwableStorage->logThrowable($ormException);
            $this->logger->error($message, LogEnvironment::fromMethodName(__METHOD__));
            return 0;
        } catch (\PDOException $pdoException) {
            throw new Exception\DatabaseConnectionException($pdoException->getMessage(), $pdoException->getCode());
        }
    }
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;
    }
61431
public function count() : int
    {
        return (int)$this->getQueryBuilder()
            ->count('*')
            ->from($this->table)
            ->execute()->fetchColumn(0);
    }
913484
public function count( $conditions = array() )
	{
		$conditions	= $this->getConditionQuery( $conditions, FALSE, TRUE, TRUE );					//  render WHERE clause if needed, foreign cursored, allow functions
		$conditions	= $conditions ? ' WHERE '.$conditions : '';
		$query	= 'SELECT COUNT(`%s`) as count FROM %s%s';
		$query	= sprintf( $query, $this->primaryKey, $this->getTableName(), $conditions );
		return (int) $this->dbc->query( $query )->fetch( \PDO::FETCH_OBJ )->count;
	}
560741
protected function filteredCount()
    {
        $this->filteredRecords = $this->filteredRecords ?: $this->count();
        if ($this->skipTotalRecords) {
            $this->totalRecords = $this->filteredRecords;
        }

        return $this->filteredRecords;
    }
1025766
protected function getTotalCount()
    {
        $query = $this->modelRepository->query();

        $this->applyListParentToQuery($query);

        return $query->count();
    }
1121904
public function count()
    {
        $this->select("COUNT(" . $this->getPrimaryKey() . ") as count");

        try {
            $results = $this->query();
        } catch (\PDOException $e) {

            throw new DatabaseException($e->getMessage() . '<br>' . $this->getLastQuery()[0]);
        }

        $results = $results->fetchAssoc();

        return $results[0]['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();
	}