Return the number of rows in this query if the limit were removed.  Useful in paged data sets.

@param string $column
@return int
185777
public function unlimitedRowCount($column = null)
    {
        // we can't clear the select if we're relying on its output by a HAVING clause
        if (count($this->having)) {
            $records = $this->execute();
            return $records->numRecords();
        }

        $clone = clone $this;
        $clone->limit = null;
        $clone->orderby = null;

        // Choose a default column
        if ($column == null) {
            if ($this->groupby) {
                // @todo Test case required here
                $countQuery = new SQLSelect();
                $countQuery->setSelect("count(*)");
                $countQuery->setFrom(array('(' . $clone->sql($innerParameters) . ') all_distinct'));
                $sql = $countQuery->sql($parameters); // $parameters should be empty
                $result = DB::prepared_query($sql, $innerParameters);
                return (int)$result->value();
            } else {
                $clone->setSelect(array("count(*)"));
            }
        } else {
            $clone->setSelect(array("count($column)"));
        }

        $clone->setGroupBy(array());
        return (int)$clone->execute()->value();
    }
654823
public function getLastInsertedId($column = null)
    {
        if (is_string($column)) {
            return $this->getConnection()->lastInsertId($column);
        }

        return $this->getConnection()->lastInsertId();
    }
1174426
public function sum($column)
    {
        $result = $this->getBuilder()->sum($column);

        // Reset query builder
        $this->resetBuilder();

        return $result ?: 0;
    }
1082481
public function getCountForPagination($column = '*')
	{
		$query = $this
			->cloneWithout(['columns', 'orders', 'limit', 'offset'])
			->cloneWithoutBindings(['select', 'order']);

		$columns = $this->withoutSelectAliases([$column]);

		// Once we have run the pagination count query, we will get the resulting count and
		// take into account what type of query it was. When there is a group by we will
		// just return the count of the entire results set since that will be correct.
		if(isset($this->groups) || count($query->havings))
		{
			$column = '*';
			if( !$columns[0] instanceof Expression && strpos($columns[0], '*') === false )
			{
				$columns[0] .= ' as uid';
				$column = 'uid';
			}

			$query = $this
				->newQuery()
				->fromSub( $query->select($columns), 'table_count' );

			$columns = [$column];
		}

		$raw = $query
			->setAggregate('count', $columns)
			->getRaw();

		if(!count($raw))
		{
			return 0;
		}

		$raw = $raw[0];
		if(is_object($raw))
		{
			return (int) $raw->aggregate;
		}
		else
		{
			return (int) array_change_key_case((array) $raw)['aggregate'];
		}
	}
645839
public function count(string $column = null): int
    {
        if (is_null($column)) {
            if (!empty($this->loader->primaryKey())) {
                //@tuneyourserver solves the issue with counting on queries with joins.
                $column = "DISTINCT({$this->loader->primaryKey()})";
            } else {
                $column = '*';
            }
        }

        return $this->compiledQuery()->count($column);
    }
1020558
public function numRows(): ?int
	{
		$regex = '/^SELECT\s+(?:ALL\s+|DISTINCT\s+)?(?:.*?)\s+FROM\s+(.*)$/i';
		$output = [];

		if (preg_match($regex, $this->lastQuery, $output) > 0)
		{
			$stmt = $this->query("SELECT COUNT(*) FROM {$output[1]}");
			return (int) $stmt->fetchColumn();
		}

		return NULL;
	}
117594
protected function runPaginationCountQuery($columns = ['*'])
    {
        $without = $this->unions ? ['orders', 'limit', 'offset'] : ['columns', 'orders', 'limit', 'offset'];

        return $this->cloneWithout($without)
                    ->cloneWithoutBindings($this->unions ? ['order'] : ['select', 'order'])
                    ->setAggregate('count', $this->withoutSelectAliases($columns))
                    ->get()->all();
    }
908660
protected function runPaginationCountQuery($columns = ['*'])
    {
        if ($this->havings) {
            $query = $this->cloneWithout(['orders', 'limit', 'offset'])
                          ->cloneWithoutBindings(['order']);

            // We don't need simple columns, only specials
            // like subselects which is why we're using
            // havings after all.
            foreach ($query->columns as $key => $value) {
                if (is_string($value)) {
                    unset($query->columns[$key]);
                }
            }

            $countQuery = DB::table(DB::raw('('.$query->toSql().') as x'))->mergeBindings($query);

            // Using a aggregate here won't work when
            // groups are present because the
            // getCountForPagination() is
            // checking for it.
            if (!$this->groups) {
                $countQuery->setAggregate('count', $this->withoutSelectAliases($columns));
            }

            return $countQuery->get()->all();
        }

        return $this->cloneWithout(['columns', 'orders', 'limit', 'offset'])
                    ->cloneWithoutBindings(['select', 'order'])
                    ->setAggregate('count', $this->withoutSelectAliases($columns))
                    ->get()->all();
    }
670181
public function getCountForPagination($columns = ['*'])
    {
        $this->backupFieldsForCount();

        $this->aggregate = ['function' => 'count', 'columns' => $this->clearSelectAliases($columns)];

        $results = $this->get();

        $this->aggregate = null;

        $this->restoreFieldsForCount();
        if (isset($this->groups)) {
            return count($results);
        }

        if (! isset($results[0])) {
            return 0;
        }

        $item = $results[0];

        if (is_object($item)) {
            return (int) $item->aggregate;
        }

        return (int) array_change_key_case((array) $item)['aggregate'];
    }
616768
public function count($column = '*')
    {
        if (!$this->DB) {
            throw  new Exception('您还没有连接数据库', Exception::CODE_DATABASE_ERROR);
        }
        $sql = $this->buildSql($column);
        $this->sql = $sql;
        /**
         * 仅仅获取sql，不实际执行
         */
        if ($this->justSql) {
            return 0;
        }
        $info = $this->DB->query($sql)->fetch(\PDO::FETCH_ASSOC);
        $this->lastQueryAt = time();
        return isset($info['num']) ? $info['num'] : 0;
    }
1286942
function columnCount() {
		$result = 0;
		if(!is_null($this->__connection))
			$result = sasql_num_fields($this->__connection);
		return $result;
	}
1318355
public function max($column)
	{
		is_array($column) and $column = array_shift($column);

		// Get the columns
		$columns = \DB::expr('MAX('.
			\Database_Connection::instance($this->connection)->quote_identifier($this->alias.'.'.$column).
			') AS max_result');

		// Remove the current select and
		$query = \DB::select($columns);

		// Set from table
		$query->from(array($this->_table(), $this->alias));

		$tmp   = $this->build_query($query, $columns, 'max');
		$query = $tmp['query'];
		$max   = $query->execute($this->connection)->get('max_result');

		// Database_Result::get('max_result') returns a string | null
		if ($max === null)
		{
			return false;
		}

		return $max;
	}
617608
public function getRowData($column = null)
    {
        $data = $this->_data->getRowData();

        if (!is_null($column)) {
            $data = isset($data[$column]) ? $data[$column] : null;
        }

        return $data;
    }
598670
public function count($column = '*', bool $distinct = false)
    {
        parent::count($column, $distinct);
        return $this->getColumnResult();
    }
1075019
public function sum(string $column): int
    {
        $sum = $this->queryRelate->getQuery()->sum($column);

        $this->resetQueryRelate();

        return $sum;
    }
1104309
public function values($column) {
		$res = [];
		while($row = $this->next())
			$res[] = $row[$column];
		return $res;
	}
437596
public static function max($column)
    {
        $self      = self::getInstance();
        
        if (empty($self->optionSelect)) {
            $self->optionSelect = "MAX({$column})";
        } else {
            $self->optionSelect .= ",MAX({$column})";
        }
        

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

        return $execute->fetchObject();
    }