Count records that match criteria
@param null $filter
@param array $options
@param int $ttl
@return mixed
334627
public function count($filter=NULL, array $options=NULL, $ttl=60) {
		$has=$this->hasCond;
		$count=$this->filteredFind($filter,$options,$ttl,true);
		$this->hasCond=$has;
		return $count;
	}
988982
public function count(array $locales = null,  array $filters = null)
    {
        $this->loadCustomHydrator();

        $builder = $this->createQueryBuilder('tu')
            ->select('COUNT(DISTINCT tu.id) AS number');

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

        return (int) $builder->getQuery()->getResult(Query::HYDRATE_SINGLE_SCALAR);
    }
913975
public function count($options)
    {
        $cmd['count'] = $options['table'];
        $cmd['query'] = $this->parseWhere($options['where']);
        foreach (['hint', 'limit', 'maxTimeMS', 'skip'] as $option) {
            if (isset($options[$option])) {
                $cmd[$option] = $options[$option];
            }
        }
        $command = new Command($cmd);
        $this->log('cmd', 'count', $cmd);
        return $command;
    }
1253616
public function countProducts($filter = null)
	{
		$timeStamp = time();
		$wStr = '';
		$qStr = 'SELECT COUNT(' . $this->entity['p']['alias'] . ')'
			. ' FROM ' . $this->entity['p']['name'] . ' ' . $this->entity['p']['alias'];

		if ($filter != null) {
			$filterStr = $this->prepareWhere($filter);
			$wStr .= ' WHERE ' . $filterStr;
		}

		$qStr .= $wStr;
		$q = $this->em->createQuery($qStr);
		$result = $q->getSingleScalarResult();
		$count = 0;
		if (!$result) {
			$count = $result;
		}
		return new ModelResponse($count, 1, 0, null, false, 'S:D:003', 'Selected entries have been successfully inserted into database.', $timeStamp, time());
	}
639808
public function findOneAndUpdate(array $filter, array $update, array $options = [])
    {
        \Tequila\MongoDB\ensureValidUpdate($update);

        $options = ['update' => (object) $update] + FindOneAndUpdateResolver::resolveStatic($options);

        return $this->findAndModify($filter, $options);
    }
53909
public function findOne(array $filter = [], array $options = [])
    {
        $options['typeMap'] = ['root' => 'array', 'document' => 'array', 'array' => 'array'];

        if ($originalValues = $this->collection->findOne($filter, $options)) {
            $values = $this->convertValues->convertToPHPValues($originalValues);


            $object = $this->hydrator->hydrate($values);

            $this->changesCollector->register($object, $originalValues);

            return $object;
        }
    }
1224430
public function deleteMany(array $filter, array $options = [])
    {
        list($bulkOptions, $options) = self::extractBulkWriteOptions($options);
        $model = new DeleteMany($filter, $options);
        $bulkWriteResult = $this->bulkWrite([$model], $bulkOptions);

        return new DeleteResult($bulkWriteResult);
    }
70932
public function handle(FilterOptionInterface $filter, array $options)
    {
        if (count($options) === 0) {
            return $filter;
        }

        $validOptions = $filter->getValidOptions();

        $this->validateFilterOptions($options, $validOptions);
        $this->setFilterOptions($filter, $options, $validOptions);

        return $filter;
    }
462318
public static function getCustomersCount($filter = array())
    {
        $filter = Filter::create($filter);
        return self::getCount('/customers/count' . $filter->toQuery());
    }
119161
public function get($filter, $cols = null) {
		$query = $this->newSelect();
		if (is_array($cols)) {
			$query->addColumns(...$cols);
		}
		if (!is_array($filter)) {
			$query->where(field($this->_primary_key)->eq($filter));
		} else {
			foreach ($filter as $k => $v) {
				$query->andWhere(field($k)->eq($v));
			}
		}
		$query->limit(1);
		$result = $this->execute($query);
		return count($result) > 0 ? current($result) : null;
	}
1082873
static public function count($filter=array())
    {
        $config = Conf::f('storage-mongodb-object', array());
        $db = isset($config['databases']) ? $config['databases'] : 'default';
        $db = DB::get($db);
        $collection = $db->selectCollection(static::getCollectionName());

        return $collection->count($filter);
    }
445833
public function findAll(array $filter = [], array $options = []): DocumentsCollection
    {
        $cursor = $this->getCollection()->find($filter, $options);

        return new DocumentsCollection($this->documentManager, $cursor, $this->documentClass);
    }
431331
public function findOneAndDelete(array $filter, array $options = [])
    {
        $options = ['remove' => true] + FindOneAndDeleteResolver::resolveStatic($options);

        return $this->findAndModify($filter, $options);
    }
149060
protected function getResultCount(Criterion $filter, array $languageFilter)
    {
        $query = $this->handler->createSelectQuery();

        $columnName = $this->handler->quoteColumn('id', 'ezcontentobject');
        $query
            ->select("COUNT( DISTINCT $columnName )")
            ->from($this->handler->quoteTable('ezcontentobject'))
            ->innerJoin(
                'ezcontentobject_version',
                'ezcontentobject.id',
                'ezcontentobject_version.contentobject_id'
            );

        $query->where(
            $this->getQueryCondition($filter, $query, $languageFilter)
        );

        $statement = $query->prepare();
        $statement->execute();

        return (int)$statement->fetchColumn();
    }
453752
public static function value($filters, $field, $ttl = null)
    {
        if (!is_string($field)) {
            throw new ParameterOrderException(__METHOD__ . ' field');
        }

        if ($ttl !== null && !is_int($ttl)) {
            throw new MisuseException('ttl must be a integer');
        }

        $model = new static;
        $pkName = $model->getPrimaryKey();

        $pkValue = null;
        if (is_scalar($filters)) {
            $pkValue = $filters;
            $filters = [$pkName => $pkValue];
        } elseif (is_array($filters)) {
            if (count($filters) === 1 && isset($filters[$pkName])) {
                $pkValue = $filters[$pkName];
            }
        }

        if ($ttl === null || $pkValue === null) {
            $rs = static::query(null, $model)->select([$field])->where($filters)->limit(1)->fetch(true);
            return $rs ? $rs[0][$field] : null;
        }

        $key = '_mp:models:value:' . $model->getSource() . ":$field:$pkValue:$ttl";
        if (($value = $model->_di->ipcCache->get($key)) !== false) {
            return $value;
        }

        $rs = static::query(null, $model)->select([$field])->whereEq($pkName, $pkValue)->limit(1)->fetch(true);
        $value = $rs ? $rs[0][$field] : null;

        $model->_di->ipcCache->set($key, $value, $ttl);

        return $value;
    }
907249
public function getRecords($filter = '', $order = ['.id'], $page = 1, $count = null, $dataDimensions = null)
    {

        if ($dataDimensions == null) {
            $dataDimensions = $this->getCurrentDataDimensions();
        }

        $caching = false;

        if ($this->isContentQueryRecordsCaching() && ($filter != '' || $count != null)) {
            $caching = true;
        }
        if ($this->isAllContentRecordsCaching() && ($filter == null && $count == null)) {
            $caching = true;
        }

        if ($caching) {

            if (!is_array($order)) {
                $order = [$order];
            }

            $cacheKey = $this->createCacheKey('records-query',
                                              [$this->getCurrentContentTypeName(), $filter, $page, $count, join(',', $order)], $dataDimensions);

            $data = $this->getCacheProvider()->fetch($cacheKey);
            if ($data) {
                $data = json_decode($data, true);

                $recordFactory = $this->getRecordFactory();
                $records       = $recordFactory->createRecordsFromJSONRecordsArray($this->getCurrentContentTypeDefinition(),
                                                                                   $data);

                foreach ($records as $record) {
                    $record->setRepository($this);
                    $record->setLanguage($dataDimensions->getLanguage());
                    $record->setWorkspace($dataDimensions->getWorkspace());
                    $record->setViewName($dataDimensions->getViewName());
                }

                return $records;
            }

            $records = parent::getRecords($filter, $order, $page, $count, $dataDimensions);

            $data = json_encode($records);

            $this->getCacheProvider()->save($cacheKey, $data, $this->contentQueryRecordsCaching);

            return $records;
        }

        return parent::getRecords($filter, $order, $page, $count, $dataDimensions);
    }
913736
public long count(final Bson filter, final RemoteCountOptions options) {
    return operations.count(filter, options).execute(service);
  }