This method is used to return an object count by the filter that is passed in.
@param Filter $filterQuery
@return int
494578
private function _countObjectsInCollectionByFilter(Filter $filterQuery)
    {
        $records = [];
        $props = [];
        $filters = [];
        foreach ($filterQuery->getComparisons() as $comparison) {
            $props[] = $comparison->prop;
            if ($comparison->expression && $comparison->comparison && $comparison->prop) {
                $expression = ($comparison->expression !== 'WHERE') ? $comparison->expression . ' ' : '';
                $prop = is_int($comparison->val) ? 'CAST(' . $comparison->prop . ' AS INT)' : $comparison->prop;
                $compare = $comparison->comparison;
                $value = (!isset($comparison->val) || is_null($comparison->val)) ? 'NULL' : $comparison->val;
                $filters[] = $expression . $prop . ' ' . $compare . ' \'' . $value . '\'';
            }
        }

        $props = array_unique($props);
        $joins = [];
        foreach ($props as $prop)
        {
            $standardFields = [
                '__id',
                '__type',
                '__collection',
                '__origin'
            ];
            if (!in_array($prop, $standardFields)) {
                $asTbl = $this->_generateAlphaToken();
                $joins[] =
                    'JOIN(' .
                        'SELECT id, val AS ' . $prop . ' ' .
                        'FROM ' . $this->_name . '__index ' .
                        'WHERE prop = \'' . $prop . '\'' .
                    ') AS ' . $asTbl . ' ' .
                    'ON A.id = ' . $asTbl . '.id';
            }
        }

        $select = Statement::get(
            'GET_OBJECTS_COUNT_BY_FILTER',
            [
                '@collection' => $this->_name,
                '@columns' => (count($props) > 0) ? ', ' . implode($props, ', ') : '',
                '@joinColumns' => (count($joins) > 0) ? implode($joins, ' ') . ' ' : '',
                '@type' => $this->_connector->quote($filterQuery->getIndexType()),
                '@filters' => ($filters) ? 'AND (' . implode($filters, ' ') . ') ' : ''
            ]
        );

        $count = $this->_connector->query($select)->fetch();
        if ($count) {
            return (int) $count[0];
        } else {
            return 0;
        }
    }
539562
public static function count($collection, $query = null)
  {
    static::checkConnexion();
    $collection = self::$db->$collection;
    if (is_string($query)) {
      $query = json_decode($query, true);
      if(!$query){
        throw new \Exception('Requête JSON formulée incorrectement');
      }
    }
    if ($query) {
      return $collection->count($query);
    } else {
      return $collection->count();
    }
  }
275710
public function countAll($executeQuery = true)
    {
        $queryBuilder = $this->createQueryBuilder('p')
            ->select('COUNT(p)');

        return $executeQuery ? $queryBuilder->getQuery()->getSingleScalarResult() : $queryBuilder;
    }
850294
private function applyFilters($filters = [], $returnCount = false)
    {
        $result = null;
        // Convert our filters into a query.
        if ($filters) {
            $alias = $this->getTableAlias();
            $query = $this->slaveQueryBuilder();
            if ($returnCount) {
                $query->select('COUNT(*)');
            } else {
                // Selecting only the id and contact_id for covering index benefits.
                $query->select($alias.'.id, '.$alias.'.contact_id');
                $query->setMaxResults(1);
            }
            $query->from(MAUTIC_TABLE_PREFIX.$this->getTableName(), $alias);

            foreach ($filters as $k => $set) {
                // Expect orx, anx, or neither.
                if (isset($set['orx'])) {
                    if (!empty($set['orx'])) {
                        $expr = $query->expr()->orX();
                    }
                    $properties = $set['orx'];
                } elseif (isset($set['andx'])) {
                    if (!empty($set['andx'])) {
                        $expr = $query->expr()->andX();
                    }
                    $properties = $set['andx'];
                } else {
                    if (!isset($expr)) {
                        $expr = $query->expr()->andX();
                    }
                    $properties = $set;
                }
                if (isset($expr) && !empty($properties)) {
                    foreach ($properties as $property => $value) {
                        if (is_array($value)) {
                            $expr->add(
                                $query->expr()->andX(
                                    $query->expr()->isNotNull($alias.'.'.$property),
                                    $query->expr()->in($alias.'.'.$property, $value)
                                )
                            );
                        } elseif (is_int($value) || is_string($value)) {
                            if (!empty($value)) {
                                $expr->add(
                                    $query->expr()->andX(
                                        $query->expr()->isNotNull($alias.'.'.$property),
                                        $query->expr()->eq($alias.'.'.$property, ':'.$property.$k)
                                    )
                                );
                            } else {
                                $expr->add(
                                    $query->expr()->eq($alias.'.'.$property, ':'.$property.$k)
                                );
                            }
                            if (in_array($property, ['category_id', 'contact_id', 'campaign_id', 'contactclient_id'])) {
                                // Explicit integers for faster queries.
                                $query->setParameter($property.$k, (int) $value, \PDO::PARAM_INT);
                            } else {
                                $query->setParameter($property.$k, $value);
                            }
                        }
                    }
                }
                if (isset($set['exclusive_expire_date'])) {
                    // Expiration/Exclusions will require an extra outer AND expression.
                    if (!isset($exprOuter)) {
                        $exprOuter  = $query->expr()->orX();
                        $expireDate = $set['exclusive_expire_date'];
                    }
                    if (isset($expr)) {
                        $exprOuter->add(
                            $query->expr()->orX($expr)
                        );
                    }
                } elseif (isset($set['contactclient_id']) && isset($set['date_added'])) {
                    $query->add(
                        'where',
                        $query->expr()->andX(
                            $query->expr()->eq($alias.'.contactclient_id', ':contactClientId'.$k),
                            $query->expr()->gte($alias.'.date_added', 'FROM_UNIXTIME(:dateAdded'.$k.')'),
                            (isset($expr) ? $expr : null)
                        )
                    );
                    $query->setParameter('contactClientId'.$k, (int) $set['contactclient_id'], \PDO::PARAM_INT);
                    $query->setParameter('dateAdded'.$k, $set['date_added']);
                }
            }
            // Expiration can always be applied globally.
            if (isset($exprOuter) && isset($expireDate)) {
                $query->add(
                    'where',
                    $query->expr()->andX(
                        $query->expr()->isNotNull($alias.'.exclusive_expire_date'),
                        $query->expr()->gte($alias.'.exclusive_expire_date', 'FROM_UNIXTIME(:exclusiveExpireDate)'),
                        $exprOuter
                    )
                );
                $query->setParameter('exclusiveExpireDate', $expireDate);
            }

            $result = $query->execute()->fetch();
            if ($returnCount) {
                $result = intval(reset($result));
            }
        }

        return $result;
    }
802758
public final function count(string $query = null, array $queryParams = null): ?int
    {
        $queryBuilder = new QueryBuilder($this->db->getLink());
        $queryBuilder->setTable($this->table);

        if ($query || $queryParams) {
            $queryBuilder->where($query, $queryParams);
        }

        return $queryBuilder->count();
    }
824475
public static long count_filtered(nitro_service service, String filter) throws Exception{
		service obj = new service();
		options option = new options();
		option.set_count(true);
		option.set_filter(filter);
		service[] response = (service[]) obj.getfiltered(service, option);
		if (response != null) {
			return response[0].__count;
		}
		return 0;
	}
608743
protected function getQueryResultCount(Select $query)
    {
        $queryString = $this->getSqlObject()->getSqlStringForSqlObject($query, $this->dbAdapter->getPlatform());

        $format = 'Select count(*) as `count` from (%s) as `query_count`';

        $countQueryString = sprintf($format, $queryString);

        $countQuery = $this->dbAdapter->query($countQueryString);

        $result = $countQuery->execute()->current();

        return (int) Arr::get($result, 'count');
    }
863057
public function countByQuery($query)
    {
        $queryCount = clone $query;
        $queryCount->setCols('count(*) as count');
        $result = $this->getDB()->execute($queryCount);

        if ($result->numRows()) {
            $row = $result->fetchResult();

            return (int)$row['count'];
        }

        return false;
    }
582393
public function count(QueryBuilderInterface $Builder) {
        $this->parsedQuery = $this->getSerialyser()->setCriteriaList($Builder)->count(true)->serialyse();
        $statement = $this->connector->query($this->parsedQuery);
        $result    = $this->statementToArray($statement);
        return (int)reset($result)->cpt;
    }
148423
public function setFilter(FilterQuery $filter)
    {
        $this->result = array_merge($this->result, $filter->toArray()['bool']);

        return $this;
    }
548569
public function getContentfulEntriesCount(?Client $client = null, ?Query $query = null): int
    {
        $client = $client ?? $this->defaultClient;

        return count($client->getEntries($query));
    }
510435
public function count($tableSpec, array $filters = [])
    {
        $filters['_id.type'] = $tableSpec;
        return $this->getCollectionForTableSpec($tableSpec)->count($filters);
    }
231806
public function getCountOfMaxPossibleFoundObjectsWithoutFilters(): int
    {
        $this->setGenerateOutputWithIterator(false);

        return (int)q_value($this->getSelectSql(true));
    }
997156
public function countLines($filter = null)
    {
        if ($filter !== null) {
            return count($this->getLines(null, 0, $filter));
        }

        return $this->lines->count();
    }
290651
public function count(): int
    {
        $query = $this->viewable->views();

        $cacheKey = Key::createForEntity($this->viewable, $this->period ?? Period::create(), $this->unique, $this->collection);

        if ($this->shouldCache) {
            $cachedViewsCount = $this->cache->get($cacheKey);

            // Return cached views count if it exists
            if ($cachedViewsCount !== null) {
                return (int) $cachedViewsCount;
            }
        }

        if ($period = $this->period) {
            $query->withinPeriod($period);
        }

        $query->where('collection', $this->collection);

        if ($this->unique) {
            $viewsCount = $query->uniqueVisitor()->count('visitor');
        } else {
            $viewsCount = $query->count();
        }

        if ($this->shouldCache) {
            $this->cache->put($cacheKey, $viewsCount, $this->cacheLifetime);
        }

        return $viewsCount;
    }
908905
public Query getCountQuery(Query aQuery)
    {
        if(aQuery instanceof QueryBySQL)
        {
            return getQueryBySqlCount((QueryBySQL) aQuery);
        }
        else if(aQuery instanceof ReportQueryByCriteria)
        {
            return getReportQueryByCriteriaCount((ReportQueryByCriteria) aQuery);
        }
        else
        {
            return getQueryByCriteriaCount((QueryByCriteria) aQuery);
        }
    }
637821
public function count($class)
    {
        $dql = "SELECT COUNT(object) FROM {$class} object";
        $query = $this->wrapped->createQuery($dql);

        return (int) $query->getSingleScalarResult();
    }