# mysqli_result 类

(PHP 5, PHP 7, PHP 8)

## 简介

代表从一个数据库查询中获取的结果集。

## 类摘要

class mysqli_result implements IteratorAggregate {
/* 属性 */
public readonly int $current_field;
public readonly int $field_count;
public readonly ?array $lengths;
public readonly int|string $num_rows;
public int $type;
/* 方法 */
public function __construct(mysqli `$mysql`, int `$result_mode` = `MYSQLI_STORE_RESULT`)
public function data_seek(int `$offset`): bool
public function fetch_all(int `$mode` = `MYSQLI_NUM`): array
public function fetch_array(int `$mode` = `MYSQLI_BOTH`): array|null|false
public function fetch_assoc(): array|null|false
public function fetch_column(int `$column` = 0): null|int|float|string|false
public function fetch_field(): object|false
public function fetch_field_direct(int `$index`): object|false
public function fetch_fields(): array
public function fetch_object(string `$class` = "stdClass", array `$constructor_args` = []): object|null|false
public function fetch_row(): array|null|false
public function field_seek(int `$index`): true
public function free(): void
public function close(): void
public function free_result(): void
public function getIterator(): Iterator
}

## 属性

type

  存储的是否为缓冲的结果，int 形式（分别是 `MYSQLI_STORE_RESULT` 或 `MYSQLI_USE_RESULT`）。

## 更新日志

版本 | 说明
--- | ---
8.0.0 | mysqli_result 现在实现 IteratorAggregate。之前实现的是 Traversable。

## 目录

- mysqli_result::__construct — Constructs a mysqli_result object
- mysqli_result::$current_field — Get current field offset of a result pointer
- mysqli_result::data_seek — Adjusts the result pointer to an arbitrary row in the result
- mysqli_result::fetch_all — Fetch all result rows as an associative array, a numeric array, or both
- mysqli_result::fetch_array — Fetch the next row of a result set as an associative, a numeric array, or both
- mysqli_result::fetch_assoc — Fetch the next row of a result set as an associative array
- mysqli_result::fetch_column — Fetch a single column from the next row of a result set
- mysqli_result::fetch_field — Returns the next field in the result set
- mysqli_result::fetch_field_direct — Fetch meta-data for a single field
- mysqli_result::fetch_fields — Returns an array of objects representing the fields in a result set
- mysqli_result::fetch_object — Fetch the next row of a result set as an object
- mysqli_result::fetch_row — Fetch the next row of a result set as an enumerated array
- mysqli_result::$field_count — Gets the number of fields in the result set
- mysqli_result::field_seek — Set result pointer to a specified field offset
- mysqli_result::free — Frees the memory associated with a result
- mysqli_result::getIterator — Retrieve an external iterator
- mysqli_result::$lengths — Returns the lengths of the columns of the current row in the result set
- mysqli_result::$num_rows — Gets the number of rows in the result set

`↑` and `↓` to navigate • `Enter` to select • `Esc` to close • `/` to open