Count the number of documents in the spec that match $filters

@param string $tableSpec Table spec ID
@param array  $filters   Query filters to get count on
@return integer
510435
public function count($tableSpec, array $filters = [])
    {
        $filters['_id.type'] = $tableSpec;
        return $this->getCollectionForTableSpec($tableSpec)->count($filters);
    }
995149
public function getMultiCount($collection, $column, array $values, array $extra = array())
	{
		$queryParts = ['SELECT COUNT(*) FROM', $collection, 'WHERE', "$column IN (?)"];

		foreach ($extra as $key => $extraValue) {
			$queryParts[] = "AND $key = ?";
		}

		$query = $this->createQueryFrom($queryParts);
		$query->setParameter(1, implode(',', $values));

		foreach ($extra as $key => $extraValue) {
			$query->setParameter($key + 2, $extraValue);
		}

		return $query->count();
	}
707608
protected function calculateAdditionalFiltersData(& $filters)
	{
		if (!empty($this->additional_filters_data)) {
			foreach ($this->additional_filters_data as $f => $src) {
				if (isset($src['query'])) {
					$filters[$f] = $this->query->pdo->query($src['query'])->fetchColumn();
				}
			}
		}
	}
456482
function count($filter=NULL,array $options=NULL,$ttl=0) {
		$fw=\Base::instance();
		$cache=\Cache::instance();
		$tag='';
		if (is_array($ttl))
			list($ttl,$tag)=$ttl;
		if (!($cached=$cache->exists($hash=$fw->hash($fw->stringify(
			[$filter])).($tag?'.'.$tag:'').'.mongo',$result)) || !$ttl ||
			$cached[0]+$ttl<microtime(TRUE)) {
			$result=$this->collection->count($filter?:[]);
			if ($fw->CACHE && $ttl)
				// Save to cache backend
				$cache->set($hash,$result,$ttl);
		}
		return $result;
	}
339282
public function replies($filters = array())
	{
		if (!isset($filters['item_id']))
		{
			$filters['item_id'] = $this->get('item_id');
		}

		if (!isset($filters['item_type']))
		{
			$filters['item_type'] = $this->get('item_type');
		}

		$entries = self::all()
			->whereEquals('parent', (int) $this->get('id'))
			->whereEquals('item_type', $filters['item_type'])
			->whereEquals('item_id', (int) $filters['item_id']);

		if (isset($filters['state']))
		{
			$entries->whereIn('state', (array) $filters['state']);
		}

		return $entries;
	}
240792
function count($filter=NULL,array $options=NULL,$ttl=0) {
		if (!($subquery_mode=($options && !empty($options['group']))))
			$this->adhoc['_rows']=['expr'=>'COUNT(*)','value'=>NULL];
		$adhoc=[];
		foreach ($this->adhoc as $key=>$field)
			// Add all adhoc fields
			// (make them available for grouping, sorting, having)
			$adhoc[]=$field['expr'].' AS '.$this->db->quotekey($key);
		$fields=implode(',',$adhoc);
		if ($subquery_mode) {
			if (empty($fields))
				// Select at least one field, ideally the grouping fields
				// or sqlsrv fails
				$fields=preg_replace('/HAVING.+$/i','',$options['group']);
			if (preg_match('/mssql|dblib|sqlsrv/',$this->engine))
				$fields='TOP 100 PERCENT '.$fields;
		}
		list($sql,$args)=$this->stringify($fields,$filter,$options);
		if ($subquery_mode)
			$sql='SELECT COUNT(*) AS '.$this->db->quotekey('_rows').' '.
				'FROM ('.$sql.') AS '.$this->db->quotekey('_temp');
		$result=$this->db->exec($sql,$args,$ttl);
		unset($this->adhoc['_rows']);
		return (int)$result[0]['_rows'];
	}
765203
public static function all($filters) {
    return function ($node) use ($filters) {
      foreach ($filters as $filter) {
        if (!$filter($node)) {
          return FALSE;
        }
      }
      return TRUE;
    };
  }
1351333
public function getMultiCount($collection, $column, array $values, array $extra = [])
    {
        $query = $this->model($collection)->whereIn($column, $values);

        return $this->addConditions($query, $extra)->count();
    }
985283
public function getRecords($filters = array())
	{
		$entries = self::all();

		$c = $entries->getTableName();
		$e = '#__extensions';

		$entries
			->select($c . '.*,' . $e . '.name')
			->join($e, $e . '.element', $c . '.component', 'inner')
			->whereEquals($e . '.type', 'component');

		if (isset($filters['component']) && $filters['component'])
		{
			$entries->whereEquals($e . '.element', $filters['component']);
		}

		return $entries
			->ordered($c . '.component', 'asc')
			->rows();
	}
23507
public function count(array $filter = [], array $options = [])
    {
        $cursor = $this->executeCommand(
            ['count' => $this->collectionName, 'query' => (object) $filter],
            $options
        );

        $result = $cursor->current();
        if (!isset($result['n'])) {
            throw new UnexpectedResultException('Command "count" did not return expected "n" field.');
        }

        return (int) $result['n'];
    }
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;
        }
    }
335924
public function countFilterBySiteIds(array $siteIds)
    {
        $qa = $this->createAggregationQuery();
        $qa->match($this->getReferenceFilter('groups', $this->generateFilterSiteId($siteIds)));

        return $this->countDocumentAggregateQuery($qa);
    }
832002
public function count($entityType, $filter = '')
	{
		$params = array('type_name' => $entityType);
		if (!empty($filter)) {
			$params['filter'] = $filter;
		}
		return $this->post('entity.count', $params);
	}
886543
public static function count($filter = []): int
    {
        /* @var $class LightModel */
        $className = get_called_class();
        $class = new $className;
        $tableKey = $class->getKeyName();

        $sql = 'SELECT COUNT(' . $tableKey . ') FROM ' . $class->getTableName() . ' WHERE 1=1';
        $params = self::handleFilter($sql, $filter, $class);

        $query = DB::getConnection()->prepare($sql);
        $query->execute($params);

        return (int) $query->fetchColumn(0);
    }
459996
public function getIssuesCount (ContextSpecificationInterface $filter = null)
	{
		$count = count($this->issues);

		foreach ($this->getChildren($filter) as $child)
		{
			$count += $child->getIssuesCount($filter);
		}

		return $count;
	}
19895
public function getResultGenerator($entity, $filters = [])
    {
        $methodName = 'get' . ucfirst($entity) . 's';

        $i = 0;
        $gotAll = false;
        while ($gotAll === false) {
            $filters['offset'] = ($i * 100);

            $result = $this->$methodName($filters);
            if (! isset($result['success']) || ! isset($result['data']) || $result['success'] !== true) {
                throw new Exception("Invalid API response: " . json_encode($result));
            }

            if (count($result['data']) < 100) {
                $gotAll = true;
            }

            foreach ($result['data'] as $item) {
                yield $item;
            }

            $i++;
        }
    }
1180222
public function addFiltersWithAndToTable(iterable $filters): self
    {
        $addWith = $this->expr()->andX();
        $this->applyFilters($addWith, $this->getTableName(), $filters);
        $addWith->count() <= 0 ?: $this->andWhere($addWith);

        return $this;
    }