# mysqli 类

(PHP 5, PHP 7, PHP 8)

## 简介

代表 PHP 与 MySQL 数据库之间的连接。

## 类摘要

class mysqli {
/* 属性 */
public readonly int|string $affected_rows;
public readonly string $client_info;
public readonly int $client_version;
public readonly int $connect_errno;
public readonly ?string $connect_error;
public readonly int $errno;
public readonly string $error;
public readonly array $error_list;
public readonly int $field_count;
public readonly string $host_info;
public readonly ?string $info;
public readonly int|string $insert_id;
public readonly string $server_info;
public readonly int $server_version;
public readonly string $sqlstate;
public readonly int $protocol_version;
public readonly int $thread_id;
public readonly int $warning_count;
/* 方法 */
public __construct(
?string `$hostname` = `null`,
?string `$username` = `null`,
#[\SensitiveParameter] ?string `$password` = `null`,
?string `$database` = `null`,
?int `$port` = `null`,
?string `$socket` = `null`
)
public autocommit(bool `$enable`): bool
public begin_transaction(int `$flags` = 0, ?string `$name` = `null`): bool
public change_user(string `$username`, #[\SensitiveParameter] string `$password`, ?string `$database`): bool
public character_set_name(): string
public close(): true
public commit(int `$flags` = 0, ?string `$name` = `null`): bool
public connect(
?string `$hostname` = `null`,
?string `$username` = `null`,
#[\SensitiveParameter] ?string `$password` = `null`,
?string `$database` = `null`,
?int `$port` = `null`,
?string `$socket` = `null`
): bool
public debug(string `$options`): true
public dump_debug_info(): bool
public execute_query(string `$query`, ?array `$params` = `null`): mysqli_result|bool
public get_charset(): ?object
#[\Deprecated]
public get_client_info(): string
public get_connection_stats(): array
public get_server_info(): string
public get_warnings(): mysqli_warning|false
#[\Deprecated]
public init(): ?bool
#[\Deprecated]
public kill(int `$process_id`): bool
public more_results(): bool
public multi_query(string `$query`): bool
public next_result(): bool
public options(int `$option`, string|int `$value`): bool
#[\Deprecated]
public ping(): bool
public static poll(
?array `&$read`,
?array `&$error`,
array `&$reject`,
int `$seconds`,
int `$microseconds` = 0
): int|false
public prepare(string `$query`): mysqli_stmt|false
public query(string `$query`, int `$result_mode` = `MYSQLI_STORE_RESULT`): mysqli_result|bool
public real_connect(
?string `$hostname` = `null`,
?string `$username` = `null`,
#[\SensitiveParameter] ?string `$password` = `null`,
?string `$database` = `null`,
?int `$port` = `null`,
?string `$socket` = `null`,
int `$flags` = 0
): bool
public real_escape_string(string `$string`): string
public real_query(string `$query`): bool
public reap_async_query(): mysqli_result|bool
#[\Deprecated]
public refresh(int `$flags`): bool
public release_savepoint(string `$name`): bool
public rollback(int `$flags` = 0, ?string `$name` = `null`): bool
public savepoint(string `$name`): bool
public select_db(string `$database`): bool
public set_charset(string `$charset`): bool
public ssl_set(
?string `$key`,
?string `$certificate`,
?string `$ca_certificate`,
?string `$ca_path`,
?string `$cipher_algos`
): true
public stat(): string|false
public stmt_init(): mysqli_stmt|false
public store_result(int `$mode` = 0): mysqli_result|false
public thread_safe(): bool
public use_result(): mysqli_result|false
}

## 目录

- mysqli::$affected_rows — Gets the number of affected rows in a previous MySQL operation
- mysqli::autocommit — 打开或关闭本次数据库连接的自动命令提交事务模式
- mysqli::begin_transaction — Starts a transaction
- mysqli::change_user — Changes the user of the database connection
- mysqli::character_set_name — 返回当前数据库连接的字符编码
- mysqli::close — 关闭先前打开的数据库连接
- mysqli::commit — 提交当前事务
- mysqli::$connect_errno — Returns the error code from last connect call
- mysqli::$connect_error — Returns a description of the last connection error
- mysqli::__construct — Open a new connection to the MySQL server
- mysqli::debug — Performs debugging operations
- mysqli::dump_debug_info — 将调试信息输出到日志
- mysqli::$errno — 返回最近函数调用的错误代码
- mysqli::$error — Returns a string description of the last error
- mysqli::$error_list — Returns a list of errors from the last command executed
- mysqli::execute_query — Prepares, binds parameters, and executes SQL statement
- mysqli::$field_count — Returns the number of columns for the most recent query
- mysqli::get_charset — Returns a character set object
- mysqli::$client_info — 获取 MySQL 客户端信息
- mysqli::$client_version — 作为整数返回 MySQL 客户端的版本
- mysqli::get_connection_stats — 返回客户端连接的统计数据
- mysqli::$host_info — 返回表述使用的连接类型的字符串
- mysqli::$protocol_version — 返回 MySQL 协议使用的版本号
- mysqli::$server_info — 返回 MySQL 服务器的版本号
- mysqli::$server_version — 作为一个整数返回MySQL服务器的版本
- mysqli::get_warnings — Get result of SHOW WARNINGS
- mysqli::$info — 返回最近执行的 SQL 语句的信息
- mysqli::init — 初始化 MySQLi 并返回用于 mysqli_real_connect() 的对象
- mysqli::$insert_id — 返回上次查询为 AUTO_INCREMENT 列生成的值
- mysqli::kill — 让服务器杀死一个 MySQL 线程
- mysqli::more_results — 检查批量查询中是否还有查询结果
- mysqli::multi_query — 在数据库上执行一个或多个查询
- mysqli::next_result — 为读取 multi_query 执行之后的下一个结果集做准备
- mysqli::options — 设置选项
- mysqli::ping — ping 一个连接，或者如果连接处于断开状态，重新连接
- mysqli::poll — 轮询连接
- mysqli::prepare — 预处理执行 SQL
- mysqli::query — 对数据库执行查询
- mysqli::real_connect — 建立一个 MySQL 服务器连接
- mysqli::real_escape_string — 根据当前连接的字符集，对于 SQL 语句中的特殊字符进行转义
- mysqli::real_query — 执行一个mysql查询
- mysqli::reap_async_query — 获取异步查询的结果
- mysqli::refresh — 刷新
- mysqli::release_savepoint — 从当前事务的保存点中移除一个命名保存点
- mysqli::rollback — 回滚当前事务
- mysqli::savepoint — 在当前事务中设置命名保存点
- mysqli::select_db — 选择用于数据库查询的默认数据库
- mysqli::set_charset — 设置客户端字符集
- mysqli::$sqlstate — 返回上一次 MySQL 操作的 SQLSTATE 错误
- mysqli::ssl_set — 用于使用 SSL 建立安全连接
- mysqli::stat — 获取当前系统状态信息
- mysqli::stmt_init — 初始化语句并返回用于 mysqli_stmt_prepare（调用）的对象
- mysqli::store_result — 传输上次查询的结果集
- mysqli::$thread_id — 返回当前连接的线程 ID
- mysqli::thread_safe — 返回是否线程安全
- mysqli::use_result — Initiate a result set retrieval
- mysqli::$warning_count — Returns the number of warnings generated by the most recently executed query

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