MySQLi Tutorial MySQLi References

The mysqli class



The mysqli class represents a connection between PHP and a MySQL database.

Class synopsis

class mysqli {
  //Properties
  int $affected_rows;
  int $connect_errno;
  ?string $connect_error;
  int $errno;
  array $error_list;
  string $error;
  int $field_count;
  ?string $client_info;
  int $client_version;
  string $host_info;
  int $protocol_version;
  string $server_info;
  int $server_version;
  ?string $info;
  int|string $insert_id;
  string $sqlstate;
  int $thread_id;
  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 get_warnings(): mysqli_warning|false
  public init(): ?false
  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 reap_async_query(): mysqli_result|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
}

❮ MySQLi Functions Reference