Count number of rows.
@param  string $what
@param  string $group_by
@return string
@api
769068
public function count($what=null, $group_by=null) {
		$r = $this->_function('COUNT', $what, $group_by);
		if(!is_array($r))
			$r = (int)$r;
		return $r;
	}
1339630
public function count(string $groupName): int
    {
        return $this->useRedis(function($resource, $redis) use($groupName){
            $key = $this->getGroupNameKey($groupName);
            return $redis->scard($key);
        });
    }
228667
public function count(...$arguments): ?int
    {
        $where       = $arguments[0] ?? null;
        $whereParams = $arguments[1] ?? null;

        $query = $this->initQueryBuilder();
        try {
            $query->select('1');

            if ($where != null) {
                $query->where($where, $whereParams);
            }

            return $query->count();
        } catch (\Exception $e) {
            $this->setFail($e);

            return null;
        }
    }
634483
public function num_rows($sqlQuery = false)
    {
        $sql = $this->buildQuery('select');
        if($sqlQuery === true) {
            return $this->getQuery();
        }
        $result = $this->executeQuery($sql);
        return $result->num_rows;
    }
1096406
final public function groupBy($by)
    {
        if (is_string($by)) {
            $by = explode(',', $by);
        }

        foreach ($by as $val) {
            $val = trim($val);

            if ($val != '') {
                $this->arrayGroupBy[] = $this->identifiers($val);

                if ($this->arrayCaching === TRUE) {
                    $this->arrayCacheGroupBy[] = $this->identifiers($val);
                    $this->arrayCacheExists[] = 'groupby';
                }
            }
        }
        return $this;
    }
1355509
public function selectCount($as = 'count', $what = null)
    {
        if (!$what) {
            $what = '`' . $this->getTable() . '`.id';
        }
        $this->getQuery()->select([$as => 'COUNT(' . $what . ')']);

        return $this;
    }
1288392
function paginateCount($conditions, $recursive){

		$sql  = $this->sql;
		return count($this->query($sql));
	}
996262
private function build_group_by( $group_by, $columns ) {
		$sql = '';
		if ( ! empty( $group_by ) ) {
			$items = [];
			foreach ( $group_by as $k ) {
				$items[] = $this->get_field_name( $k, $columns );
			}
			if ( ! empty( $items ) ) {
				$sql .= ' GROUP BY ' . implode( ', ', $items );
			}
		}

		return $sql;
	}
1266563
public function countResult($wheres = [], $selectField = '*')
    {
        if (!is_array($selectField)) {
            $selectField = [$selectField];
        }
        $db = $this->db->select($selectField)->from($this->table);
        if (is_array($wheres) && count($wheres) > 0) {
            foreach ($wheres as $field => $value) {
                if (is_array($value)) {
                    $db->whereIn($field, $value);
                } else {
                    $db->where($field, self::OPERATOR_EQUAL_TO, $value);
                }
            }
        } else {
            $db->where($this->primaryKey, self::OPERATOR_EQUAL_TO, $wheres);
        }
        $totalItem = $db->execute()->rowCount();
        $this->debug->debug(__FUNCTION__, 'Total Item Result => ' . json_encode($totalItem));

        return $totalItem;
    }
1047018
public function count()
    {
        if (empty($this->queryString)) {
            $builder = clone $this->builder;
            $builder->resetQueryPart('orderBy');
            $stmt = $builder->execute();
        } else {
            $stmt = $this->connection->executeQuery($this->queryString, $this->queryParams);
        }

        return (int) $stmt->rowCount();
    }
1065190
protected function generate_count_records_sql(string $wheresql = null) : string {
        $alias = $this->get_table_alias();
        $db = $this->get_db();

        $selectsql = "SELECT COUNT(1) FROM {" . self::TABLE . "} {$alias}";
        $selectsql .= $wheresql ? ' WHERE ' . $wheresql : '';

        return $selectsql;
    }
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'];
	}
1101560
public function countWhere($where, array $values = [])
    {
        $sql = sprintf(
            "select count(*) as result from %s where :condition",
            $this->getStructure()->getRelation()
        );

        return $this->fetchSingleValue($sql, $where, $values);
    }
543597
public static function count()
    {
        $self      = self::getInstance();

        $statement = $self->makeSelect();
        $execute   = $self->exec($statement, []);

        return $execute->rowCount();
    }
1370138
public function get_events_select_count($selectwhere, array $params) {
        if (!$this->init()) {
            return 0;
        }

        if (!$dbtable = $this->get_config('dbtable')) {
            return 0;
        }

        return $this->extdb->count_records_select($dbtable, $selectwhere, $params);
    }
342076
public function countBy(array $where = [])
    {
        $query = $this->make();

        $query = $this->applyWhere($query, $where);

        return $query->count();
    }
1216107
public function getCount($where = '', $variables = null)
    {
        $where = $this->formatWhereClause($where);

        $response = $this->driver->query("select count(*) as numberOfItems from " . $this->getTable() . ' ' . $where . ";", $variables);

        if (!$response->count()) return 0;

        $response = $response->row();

        return intval($response->numberOfItems);
    }