Fetch total amount of records condoning to a set of conditions

@param String $modelName The entity name
@param Array $conditions Query modifiers
@return Int
427888
protected function _fetchTotal($modelName, $conditions) {
        if (!array_key_exists('query', $conditions)) {
            $conditions['query'] = array();
        }
        $man = new Garp_Content_Manager($modelName);
        return $man->count($conditions);
    }
719215
protected function getModelInstanceQuery(Model $model)
    {
        $query = $model->query();

        $this->applyOrderingToModelInstanceQuery($query);
        $this->applyStartAndStopLimitsToQuery($query);

        return $query;
    }
528928
public function count($collectionName, $condition = [], $options = [])
    {
        $document = ['count' => $collectionName];

        if (!empty($condition)) {
            $document['query'] = (object) $this->buildCondition($condition);
        }

        return array_merge($document, $options);
    }
1215192
public function fetchCount($where=array()) {
        $obj = $this->getConnection();
        if (empty($where) == false) {
            foreach ($where as $key => $value) {
                $obj->where($key, $value);
            }
        }
        $count = $obj->getValue($this->getDao()->getTableName(), 'count(1)');
        return (int)$count;
	}
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;
	}
232572
public function countContentsByClassname($classname = array())
    {
        $result = 0;
        if (!is_array($classname)) {
            return $result;
        }
        $db = $this->_em->getConnection();
        $stmt = $db->executeQuery('SELECT count(*) as total FROM `content` WHERE `classname` IN (?)', array($classname), array(\Doctrine\DBAL\Connection::PARAM_STR_ARRAY));

        $result = $stmt->fetchColumn();

        return $result;
    }
409289
public function count(array $parameters = [])
    {
        $this->manager->commit();
        $count = $this->applyFilters(
            $this->queryBuilder
                ->select('count(*) as count')
                ->from($this->entity->getTable(), $this->alias)
        )->query(array_merge($this->parameters, $parameters))->fetch();

        return $count['count'];
    }
1280384
public function reduce($modelName)
    {
        $file = self::getMapper();

        $finalMaps = [];

        if (File::Exists($file)) {

            $maps = self::getMaps($file);

            $existingMaps = Collect($maps)->filter(function ($map) use ($modelName) {
                return !$this->mapExists($map, $modelName);
            });

            foreach ($existingMaps as $existingMap) {
                $finalMaps[] = (object) $existingMap;
            }
        }

        File::put($file, Helpers::prettifyJson($finalMaps));
    }
231955
public static function findByName( $modelId, $name ) {

		$query	= self::queryByName( $modelId, $name );

		return $query->all();
	}
671909
public function queryAndCount($resultName, $countName, QueryObjectInterface $queryObject, DisplayCriteriaInterface $displayCriteria = null)
    {
        list($result, $count) = $this->doQueryAndCount($queryObject, $displayCriteria);

        $this->data[$resultName] = $result;
        $this->data[$countName] = $count;

        return [$result, $count];
    }
268751
public static function count($args = false)
    {
        /* @var ActiveRecord $model */

        $query = null;
        $model = new static();

        if ($args && $args instanceof Query) {
            $query = $args;
            //$query->from = " (SELECT T.".$model->getPkName()." FROM ".$model->getTableName()." T) TEMP";
            if (empty($query->from)) {
                $query->addFrom($model->getTableName().' T');
            }
            $query->select = 'T.'.$model->getPkName();
        } elseif ($args && is_array($args)) {
            if (!isset($args['from'])) {
                $args['from'] = $model->getTableName().' T';
            }
            $query = new Query($args);
            //$query->select = 'COUNT(*)';
            $query->select = 'T.'.$model->getPkName();
        } elseif (!$args) {
            $query = new Query(
                [
                    'from' => $model->getTableName().' T',
                    'select' => 'T.'.$model->getPkName(),
                ]
            );
        } else {
            throw new Exception(translate('Bad arguments'), 500, Exception::BADARGUMENTS);
        }

        $count_query = new Query(
            [
                'select' => 'COUNT(*)',
                'from' => '('.$query->toSql().') TC',
            ]
        );

        $stmt = $model->getDB()->prepare($count_query->toSql());
        $stmt->execute($query->params);
        $records = $stmt->fetchColumn();

        $stmt->closeCursor();

        return $records;
    }
1023166
public function one(string $condition = '', array $params = []) {
        $this->model->builder->select('*')
            ->from($this->model->tableName);
        if ($condition) {
            $this->model->builder->where($condition, $params);
        }
        $r = $this->model->builder->limit(1)
            ->query();
        if (!is_array($r) || 0 === count($r)) {
            return null;
        }
        return $this->model->setup($r[0]);
    }
1183717
public function count($tableName, $condition = '') {
		if ($condition != '')
			$condition = " WHERE " . $condition;
		return $this->query ( "SELECT COUNT(*) FROM " . $tableName . $condition )->fetchColumn ();
	}
107649
public function findMany($conditions = '', $params = array(), $orderBy = null, $limit = null, $offset = null){
        $cmd = $this->db->builder()->select()->from($this->table)->where($conditions, $params);
        if($orderBy){
            $cmd->orderBy($orderBy);
        }
        $rows = $cmd->limit($limit, $offset)->queryAll();
        if(false === $rows){
            return false;
        }
        else{
            return $this->mapModels($rows);
        }
    }
1283394
public static function count($table, $condition, $field = '1')
    {
        $db = self::Using(self::$using_dbo_id);
        return $db->count($table, $condition, $field);
    }
287643
public function rowsPerPage($modelName)
    {
        $dataTable = app('admin_datatable');

        //get the inputted rows and the model rows
        $rows = (int) $this->request->input('rows', 20);
        $dataTable->setRowsPerPage(app('session.store'), 0, $rows);

        return response()->JSON(array('success' => true));
    }
1006783
public function count($conditions = '', $params = array()){
        return $this->db->builder()->select('COUNT(*)')->from($this->table)->where($conditions, $params)->queryValue();
    }