The mysqli class

(PHP 5, PHP 7, PHP 8)

Introduction

Represents a connection between PHP and a MySQL database.

Class synopsis

class mysqli {
/* Properties */
public int|string $affected_rows;
public string $client_info;
public int $client_version;
public int $connect_errno;
public ?string $connect_error;
public int $errno;
public string $error;
public array $error_list;
public int $field_count;
public string $host_info;
public ?string $info;
public int|string $insert_id;
public string $server_info;
public int $server_version;
public string $sqlstate;
public int $protocol_version;
public int $thread_id;
public int $warning_count;
/* Methods */
public __construct(
    string $hostname = ini_get("mysqli.default_host"),
    string $username = ini_get("mysqli.default_user"),
    string $password = ini_get("mysqli.default_pw"),
    string $database = "",
    int $port = ini_get("mysqli.default_port"),
    string $socket = ini_get("mysqli.default_socket")
)
public autocommit(bool $enable): bool
public begin_transaction(int $flags = 0, ?string $name = null): bool
public change_user(string $username, string $password, ?string $database): bool
public character_set_name(): string
public close(): bool
public commit(int $flags = 0, ?string $name = null): bool
public connect(
    string $hostname = ini_get("mysqli.default_host"),
    string $username = ini_get("mysqli.default_user"),
    string $password = ini_get("mysqli.default_pw"),
    string $database = "",
    int $port = ini_get("mysqli.default_port"),
    string $socket = ini_get("mysqli.default_socket")
): void
public debug(string $options): bool
public dump_debug_info(): bool
public get_charset(): ?object
public get_client_info(): string
public get_connection_stats(): array
public get_server_info(): string
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
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 $host = ?,
    string $username = ?,
    string $passwd = ?,
    string $dbname = ?,
    int $port = ?,
    string $socket = ?,
    int $flags = ?
): bool
public real_escape_string(string $string): string
public real_query(string $query): bool
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
): bool
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
}

Table of Contents