PHP MySQLi



Introduction to PHP MySQLi

PHP MySQLi = PHP MySQL Improved!

The MySQLi functions allow you to access the MySQL database server.

Note: The MySQLi extension is designed to work with MySQL version 4.1.13 or later.


Installation/Runtime Configuration

In order to use MySQLi functions smoothly, you must add support for the MySQLi extension when compiling PHP.

The MySQLi extension was introduced in PHP version 5.0.0. MySQL Native Driver is included in PHP version 5.3.0.

For more information about installation, please visit: http://www.php.net/manual/en/mysqli.installation.php

For more information about running configuration, please visit: http://www.php.net/manual/en/mysqli.configuration.php


PHP 5 MySQLi Function

FunctionDescription
mysqli_affected_rows()Returns the number of record rows affected by the previous MySQL operation.
mysqli_autocommit()Turn on or off automatic submission of database modifications.
mysqli_change_user()Change the user for the specified database connection.
mysqli_character_set_name()Returns the default character set for the database connection.
mysqli_close()Close the previously opened database connection.
mysqli_commit()Commit the current transaction.
mysqli_connect_errno()Returns the error code of the last connection error.
mysqli_connect_error() Returns the error description of the last connection error.
mysqli_connect()Open a new connection to the MySQL server.
mysqli_data_seek()Adjust the result pointer to an arbitrary row in the result set.
mysqli_debug()Perform debugging operations.
mysqli_dump_debug_info()Dump debugging information into the log.
mysqli_errno()Returns the last error code of the most recently called function.
mysqli_error_list()Returns the error list of the most recently called function.
mysqli_error()Returns the last error description of the most recently called function.
mysqli_fetch_all() Get all rows from the result set as an associative array, a numeric array, or both.
mysqli_fetch_array()Get a row from the result set as an associative array, a numeric array, or both.
mysqli_fetch_assoc()Get a row from the result set as an associative array.
mysqli_fetch_field_direct()Get the meta-data of a single field from the result set and return it as an object.
mysqli_fetch_field()Get the next field from the result set and return it as an object.
mysqli_fetch_fields()Returns an array of objects representing fields in the result.
mysqli_fetch_lengths()Returns the length of each column of the current row in the result set.
mysqli_fetch_object()Get the current row from the result set and return it as an object.
mysqli_fetch_row()Gets a row from the result set and returns it as an enumeration array.
mysqli_field_count()Returns the number of columns recently queried.
mysqli_field_seek()Sets the pointer in the result set to the offset of the specified field.
mysqli_field_tell()Returns the position of the pointer in the result set.
mysqli_free_result()Release the result memory.
mysqli_get_charset() Returns the character set object.
mysqli_get_client_info()Returns the MySQL client library version.
mysqli_get_client_stats()Return statistics about each process of the client.
mysqli_get_client_version()Returns the MySQL client library version as an integer.
mysqli_get_connection_stats()Return statistics about client connections.
mysqli_get_host_info()Returns the MySQL server host name and connection type.
mysqli_get_proto_info()Returns the MySQL protocol version.
mysqli_get_server_info()Returns the MySQL server version.
mysqli_get_server_version()Returns the MySQL server version as an integer.
mysqli_info()Returns information about the most recently executed query.
mysqli_init()Initialize MySQLi and return the resources used by mysqli_real_connect().
mysqli_insert_id()Returns the automatically generated ID from the last query.
mysql_kill()Requests the server to kill a MySQL thread.
mysqli_more_results() Checks whether a multi-query has more results.
mysqli_multi_query()Execute one or more queries against the database.
mysqli_next_result() Prepare the next result set for mysqli_multi_query().
mysqli_num_fields()Returns the number of fields in the result set.
mysqli_num_rows()Returns the number of rows in the result set.
mysqli_options() Set additional connection options to affect connection behavior.
mysqli_ping() Make a server connection and try to reconnect if the connection is disconnected.
mysqli_prepare() Prepare to execute a SQL statement.
mysqli_query()Execute a query against the database.
mysqli_real_connect()Open a new link to the MySQL server.
mysqli_real_escape_string()Escape special characters in strings used in SQL statements.
mysqli_real_query()Execute SQL query
mysqli_reap_async_query()Return the results of asynchronous query .
mysqli_refresh()Refresh the table or cache, or reset the replication server information.
mysqli_rollback()Roll back the current transaction in the database.
mysqli_select_db()Change the default database for the connection.
mysqli_set_charset()Set the default client character set.
mysqli_set_local_infile_default()Revoke the user-defined handle used for the load local infile command.
mysqli_set_local_infile_handler()Set the rollback function for the LOAD DATA LOCAL INFILE command.
mysqli_sqlstate()Returns the SQLSTATE error code of the last MySQL operation.
mysqli_ssl_set() Used to create an SSL secure connection.
mysqli_stat()Return the current system status.
mysqli_stmt_init()Initializes the statement and returns the object used by mysqli_stmt_prepare().
mysqli_store_result()Transmit the result set of the last query.
mysqli_thread_id()Returns the thread ID of the current connection.
mysqli_thread_safe()Returns whether the client library is compiled into thread-safe.
mysqli_use_result()Initializes the retrieval of the result set from the last query executed using mysqli_real_query().
mysqli_warning_count()Returns the number of warnings for the last query in the connection.