mysqli
class mysqli (View source)
Represents a connection between PHP and a MySQL database.
Properties
int | $affected_rows | ||
string | $client_info | ||
int | $client_version | ||
int | $connect_errno | ||
string | $connect_error | ||
int | $errno | ||
string | $error | ||
int | $field_count | ||
string | $host_info | ||
string | $info | ||
int|string | $insert_id | ||
string | $server_info | ||
int | $server_version | ||
string | $sqlstate | ||
int | $protocol_version | ||
int | $thread_id | ||
int | $warning_count | ||
array | $error_list | ||
$stat |
Methods
Open a new connection to the MySQL server
Turns on or off auto-committing database modifications
Starts a transaction
Changes the user of the specified database connection
Returns the current character set of the database connection
No description
Closes a previously opened database connection
Commits the current transaction
No description
Dump debugging information into the log
Performs debugging operations
Returns a character set object
Prepares the SQL query, binds parameters, and executes it. The mysqli::execute_query() method is a shortcut for mysqli::prepare(), mysqli_stmt::bind_param(), mysqli_stmt::execute(), and mysqli_stmt::get_result().
The statement template can contain zero or more question mark (?) parameter markers—also called placeholders. The parameter values must be provided as an array using params parameter.
A prepared statement is created under the hood but it's never exposed outside of the function. It's impossible to access properties of the statement as one would do with the mysqli_stmt object. Due to this limitation, the status information is copied to the mysqli object and is available using its methods, e.g. mysqli_affected_rows() or mysqli_error().
Returns the MySQL client version as a string
Returns statistics about the client connection
Returns the version of the MySQL server
Get result of SHOW WARNINGS
Asks the server to kill a MySQL thread
Performs one or more queries on the database
No description
Check if there are any more query results from a multi query
Prepare next result from multi_query
Set options
Pings a server connection, or tries to reconnect if the connection has gone down
Prepares an SQL statement for execution
Performs a query on the database
Opens a connection to a mysql server
Escapes special characters in a string for use in an SQL statement, taking into account the current charset of the connection
Poll connections
Get result from async query
Escapes special characters in a string for use in an SQL statement, taking into account the current charset of the connection
Execute an SQL query
Removes the named savepoint from the set of savepoints of the current transaction
Rolls back current transaction
Set a named transaction savepoint
Selects the default database for database queries
Sets the client character set
No description
Used for establishing secure connections using SSL
Gets the current system status
Initializes a statement and returns an object for use with mysqli_stmt_prepare
Transfers a result set from the last query
Returns whether thread safety is given or not
Initiate a result set retrieval
No description
Details
__construct(string $hostname = null, string $username = null, string $password = null, string $database = null, int $port = null, string $socket = null)
Open a new connection to the MySQL server
bool
autocommit(bool $enable)
Turns on or off auto-committing database modifications
bool
begin_transaction(int $flags = 0, string $name = null)
Starts a transaction
bool
change_user(string $username, string $password, string|null $database)
Changes the user of the specified database connection
string
character_set_name()
Returns the current character set of the database connection
client_encoding()
No description
bool
close()
Closes a previously opened database connection
bool
commit(int $flags = 0, string|null $name = null)
Commits the current transaction
bool
connect(string|null $hostname = null, string|null $username = null, string|null $password = null, string|null $database = null, int|null $port = null, string|null $socket = null)
No description
bool
dump_debug_info()
Dump debugging information into the log
bool
debug(string $options)
Performs debugging operations
object|null
get_charset()
Returns a character set object
mysqli_result|bool
execute_query(string $query, array|null $params = null)
Prepares the SQL query, binds parameters, and executes it. The mysqli::execute_query() method is a shortcut for mysqli::prepare(), mysqli_stmt::bind_param(), mysqli_stmt::execute(), and mysqli_stmt::get_result().
The statement template can contain zero or more question mark (?) parameter markers—also called placeholders. The parameter values must be provided as an array using params parameter.
A prepared statement is created under the hood but it's never exposed outside of the function. It's impossible to access properties of the statement as one would do with the mysqli_stmt object. Due to this limitation, the status information is copied to the mysqli object and is available using its methods, e.g. mysqli_affected_rows() or mysqli_error().
string
get_client_info()
Returns the MySQL client version as a string
array
get_connection_stats()
Returns statistics about the client connection
string
get_server_info()
Returns the version of the MySQL server
mysqli_warning|false
get_warnings()
Get result of SHOW WARNINGS
bool|null
init()
deprecated
deprecated
Initializes MySQLi object
bool
kill(int $process_id)
Asks the server to kill a MySQL thread
bool
multi_query(string $query)
Performs one or more queries on the database
mysqli(string $host = null, string $username = null, string $password = null, string $database = null, int $port = null, string $socket = null)
No description
bool
more_results()
Check if there are any more query results from a multi query
bool
next_result()
Prepare next result from multi_query
bool
options(int $option, string|int $value)
Set options
bool
ping()
Pings a server connection, or tries to reconnect if the connection has gone down
mysqli_stmt|false
prepare(string $query)
Prepares an SQL statement for execution
mysqli_result|bool
query(string $query, int $result_mode = MYSQLI_STORE_RESULT)
Performs a query on the database
bool
real_connect(string $hostname = null, string $username = null, string $password = null, string $database = null, int $port = null, string $socket = null, int $flags = 0)
Opens a connection to a mysql server
string
real_escape_string(string $string)
Escapes special characters in a string for use in an SQL statement, taking into account the current charset of the connection
static int|false
poll(array $read, array $error, array $reject, int $seconds, int $microseconds = 0)
Poll connections
mysqli_result|bool
reap_async_query()
Get result from async query
string
escape_string(string $string)
Escapes special characters in a string for use in an SQL statement, taking into account the current charset of the connection
bool
real_query(string $query)
Execute an SQL query
bool
release_savepoint(string $name)
Removes the named savepoint from the set of savepoints of the current transaction
bool
rollback(int $flags = 0, string $name = null)
Rolls back current transaction
bool
savepoint(string $name)
Set a named transaction savepoint
bool
select_db(string $database)
Selects the default database for database queries
bool
set_charset(string $charset)
Sets the client character set
bool
set_opt(int $option, string|int $value)
No description
bool
ssl_set(string|null $key, string|null $certificate, string|null $ca_certificate, string|null $ca_path, string|null $cipher_algos)
Used for establishing secure connections using SSL
string|false
stat()
Gets the current system status
mysqli_stmt|false
stmt_init()
Initializes a statement and returns an object for use with mysqli_stmt_prepare
mysqli_result|false
store_result(int $mode = 0)
Transfers a result set from the last query
bool
thread_safe()
Returns whether thread safety is given or not
mysqli_result|false
use_result()
Initiate a result set retrieval
bool
refresh(int $flags)
No description