Count records according to given criteria

@param Array $options Options
@return Int
12566
public function count(array $options = null) {
        if ($this->_model instanceof Garp_Model_Db) {
            unset($options['sort']);
            $options['fields'] = 'COUNT(*)';
            try {
                $result = $this->fetch($options);
                return !empty($result[0]['COUNT(*)']) ? $result[0]['COUNT(*)'] : 0;
            } catch (Zend_Db_Statement_Exception $e) {
                /**
                 * @todo When fetching results
                 * filtered using a HABTM relationship, extra
                 * meta field are returned from the binding table.
                 * This results in an SQL error; when using COUNT()
                 * and returning results from multiple tables a
                 * GROUP BY clause is mandatory. This must be fixed in
                 * the future.
                 */
                return 1000;
            }
        } else {
            return $this->_model->count();
        }
    }
516261
public function count(array $locales = null,  array $filters = null)
    {
        $builder = $this->createQueryBuilder();

        $this->addTransUnitFilters($builder, $filters);
        $this->addTranslationFilter($builder, $locales, $filters);

        $count = $builder->count()
            ->getQuery()
            ->execute();

        return $count;
    }
962852
public function countRemoteHistoryContaos(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
    {
        $partial = $this->collRemoteHistoryContaosPartial && !$this->isNew();
        if (null === $this->collRemoteHistoryContaos || null !== $criteria || $partial) {
            if ($this->isNew() && null === $this->collRemoteHistoryContaos) {
                return 0;
            }

            if ($partial && !$criteria) {
                return count($this->getRemoteHistoryContaos());
            }
            $query = RemoteHistoryContaoQuery::create(null, $criteria);
            if ($distinct) {
                $query->distinct();
            }

            return $query
                ->filterByRemoteApp($this)
                ->count($con);
        }

        return count($this->collRemoteHistoryContaos);
    }
1004546
public function countChildren(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
    {
        $partial = $this->collChildrenPartial && !$this->isNew();
        if (null === $this->collChildren || null !== $criteria || $partial) {
            if ($this->isNew() && null === $this->collChildren) {
                return 0;
            }

            if ($partial && !$criteria) {
                return count($this->getChildren());
            }

            $query = ChildSkillDependencyQuery::create(null, $criteria);
            if ($distinct) {
                $query->distinct();
            }

            return $query
                ->filterBySkillRelatedByDependencyId($this)
                ->count($con);
        }

        return count($this->collChildren);
    }
502444
public function countM2Ps(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
    {
        $partial = $this->collM2PsPartial && !$this->isNew();
        if (null === $this->collM2Ps || null !== $criteria || $partial) {
            if ($this->isNew() && null === $this->collM2Ps) {
                return 0;
            }

            if ($partial && !$criteria) {
                return count($this->getM2Ps());
            }

            $query = ChildM2PQuery::create(null, $criteria);
            if ($distinct) {
                $query->distinct();
            }

            return $query
                ->filterByMedia($this)
                ->count($con);
        }

        return count($this->collM2Ps);
    }
718414
public function countPictures(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
    {
        $partial = $this->collPicturesPartial && !$this->isNew();
        if (null === $this->collPictures || null !== $criteria || $partial) {
            if ($this->isNew() && null === $this->collPictures) {
                return 0;
            }

            if ($partial && !$criteria) {
                return count($this->getPictures());
            }

            $query = ChildPictureQuery::create(null, $criteria);
            if ($distinct) {
                $query->distinct();
            }

            return $query
                ->filterBySkill($this)
                ->count($con);
        }

        return count($this->collPictures);
    }
243564
public function count(array $criteria)
    {
        return $this->em->getUnitOfWork()->getEntityPersister($this->entityName)->count($criteria);
    }
1338872
public static function count($count, array $options = []) {

        // TODO: Refactor the options to a dedicated config file.
        $classes = Arr::get($options, 'classes', [
            'positive' => 'label label-info',
            'zero'     => 'label label-default',
            'negative' => 'label label-danger',
        ]);

        return static::generate($count, [
            'class' => $count > 0 ? $classes['positive'] : ($count < 0 ? $classes['negative'] : $classes['zero'])
        ]);
    }
954141
public function countBy(array $criteria = null)
    {
        /** @var \Doctrine\ORM\QueryBuilder $qb */
        $qb = $this->createQueryBuilder('e');
        $qb->select('count(e.id)');

        $firstCriteria = true;
        if (!empty($criteria)) {
            foreach ($criteria as $field => $value) {
                if ($firstCriteria) {
                    if ($value === null or $value === 'null') {
                        $qb->where("e.$field IS NULL");
                    } elseif ($value === 'not null') {
                        $qb->where("e.$field IS NOT NULL");
                    } else {
                        $qb->where("e.$field = :$field");
                        $qb->setParameter($field, $value);
                    }

                    $firstCriteria = false;
                } else {
                    if ($value === null or $value === 'null') {
                        $qb->andWhere("e.$field IS NULL");
                    } elseif ($value === 'not null') {
                        $qb->andWhere("e.$field IS NOT NULL");
                    } else {
                        $qb->andWhere("e.$field = :$field");
                        $qb->setParameter($field, $value);
                    }
                }
            }
        }

        return $qb->getQuery()->getSingleScalarResult();
    }
599815
public function countRootSkills(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
    {
        $partial = $this->collRootSkillsPartial && !$this->isNew();
        if (null === $this->collRootSkills || null !== $criteria || $partial) {
            if ($this->isNew() && null === $this->collRootSkills) {
                return 0;
            }

            if ($partial && !$criteria) {
                return count($this->getRootSkills());
            }

            $query = ChildSkillQuery::create(null, $criteria);
            if ($distinct) {
                $query->distinct();
            }

            return $query
                ->filterByKstrukturRoot($this)
                ->count($con);
        }

        return count($this->collRootSkills);
    }
463892
public function getServiceAccount(array $options = [])
    {
        $resp = $this->connection->getServiceAccount($options + ['projectId' => $this->projectId]);
        return $resp['email'];
    }
53881
public function count(array $filters, array $options = [])
    {
        $data = [
            'body' => $filters
        ];

        $response = $this->kuzzle->query(
            $this->buildQueryArgs('document', 'count'),
            $this->kuzzle->addHeaders($data, $this->headers),
            $options
        );

        return $response['result']['count'];
    }
1151855
public function countDealerAdmins(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
    {
        $partial = $this->collDealerAdminsPartial && !$this->isNew();
        if (null === $this->collDealerAdmins || null !== $criteria || $partial) {
            if ($this->isNew() && null === $this->collDealerAdmins) {
                return 0;
            }

            if ($partial && !$criteria) {
                return count($this->getDealerAdmins());
            }

            $query = ChildDealerAdminQuery::create(null, $criteria);
            if ($distinct) {
                $query->distinct();
            }

            return $query
                ->filterByDealer($this)
                ->count($con);
        }

        return count($this->collDealerAdmins);
    }
913736
public long count(final Bson filter, final RemoteCountOptions options) {
    return operations.count(filter, options).execute(service);
  }
982704
public function countSkillsRelatedByEndPositionId(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
    {
        $partial = $this->collSkillsRelatedByEndPositionIdPartial && !$this->isNew();
        if (null === $this->collSkillsRelatedByEndPositionId || null !== $criteria || $partial) {
            if ($this->isNew() && null === $this->collSkillsRelatedByEndPositionId) {
                return 0;
            }

            if ($partial && !$criteria) {
                return count($this->getSkillsRelatedByEndPositionId());
            }

            $query = ChildSkillQuery::create(null, $criteria);
            if ($distinct) {
                $query->distinct();
            }

            return $query
                ->filterByEndPosition($this)
                ->count($con);
        }

        return count($this->collSkillsRelatedByEndPositionId);
    }
638649
public function countMultiples(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
    {
        $partial = $this->collMultiplesPartial && !$this->isNew();
        if (null === $this->collMultiples || null !== $criteria || $partial) {
            if ($this->isNew() && null === $this->collMultiples) {
                return 0;
            }

            if ($partial && !$criteria) {
                return count($this->getMultiples());
            }

            $query = ChildSkillQuery::create(null, $criteria);
            if ($distinct) {
                $query->distinct();
            }

            return $query
                ->filterByMultipleOf($this)
                ->count($con);
        }

        return count($this->collMultiples);
    }
115995
public static function getRevisionRecords($options = [])
    {
        $options = Util::prepareOptions($options, [
            'indexField' => false,
            'conditions' => [],
            'order' => false,
            'limit' => false,
            'offset' => 0,
        ]);

        $query = 'SELECT * FROM `%s` WHERE (%s)';
        $params = [
            static::getHistoryTable(),
            count($options['conditions']) ? join(') AND (', static::_mapConditions($options['conditions'])) : 1,
        ];

        if ($options['order']) {
            $query .= ' ORDER BY ' . join(',', static::_mapFieldOrder($options['order']));
        }

        if ($options['limit']) {
            $query .= sprintf(' LIMIT %u,%u', $options['offset'], $options['limit']);
        }


        if ($options['indexField']) {
            return DB::table(static::_cn($options['indexField']), $query, $params);
        } else {
            return DB::allRecords($query, $params);
        }
    }