MySQL Improved Extension mysqli
&reftitle.intro; The mysqli extension allows you to access the functionality provided by MySQL 4.1 and above. More information about the MySQL Database server can be found at &url.mysql; Documentation for MySQL can be found at &url.mysql.docs;. Parts of this documentation included from MySQL manual with permissions of MySQL AB.
&reftitle.required; In order to have these functions available, you must compile PHP with support for the mysqli extension. The mysqli extension is designed to work with the version 4.1.3 or above of MySQL. For previous versions, please see the MySQL extension documentation.
&reference.mysqli.configure; &reference.mysqli.ini;
&reftitle.classes;
<classname>mysqli</classname> Represents a connection between PHP and a MySQL database.
&reftitle.constructor; mysqli - construct a new mysqli object
&reftitle.methods; autocommit - turns on or off auto-commiting database modifications change_user - changes the user of the specified database connection character_set_name - returns the default character set for the database connection close - closes a previously opened connection commit - commits the current transaction connect - opens a new connection to MySQL database server debug - performs debugging operations dump_debug_info - dumps debug information get_client_info - returns client version get_host_info - returns type of connection used get_server_info - returns version of the MySQL server get_server_version - returns version of the MySQL server init - initializes mysqli object info - retrieves information about the most recently executed query kill - asks the server to kill a mysql thread multi_query - performs multiple queries more_results - check if more results exist from currently executed multi-query next_result - reads next result from currently executed multi-query options - set options ping - pings a server connection or reconnects if there is no connection prepare - prepares a SQL query query - performs a query real_connect - attempts to open a connection to MySQL database server escape_string - escapes special characters in a string for use in a SQL statement, taking into account the current charset of the connection rollback - rolls back the current transaction select_db - selects the default database set_charset - sets the default client character set ssl_set - sets ssl parameters stat - gets the current system status stmt_init- initializes a statement for use with mysqli_stmt_prepare store_result - transfers a resultset from last query thread_safe - returns whether thread safety is given or not use_result - transfers an unbuffered resultset from last query
&reftitle.properties; affected_rows - gets the number of affected rows in a previous MySQL operation client_info - returns the MySQL client version as a string client_version - returns the MySQL client version as an integer errno - returns the error code for the most recent function call error - returns the error string for the most recent function call field_count - returns the number of columns for the most recent query host_info - returns a string representing the type of connection used info - retrieves information about the most recently executed query insert_id - returns the auto generated id used in the last query protocol_version - returns the version of the MySQL protocol used server_info - returns a string that represents the server version number server_version - returns the version number of the server as an integer sqlstate - returns a string containing the SQLSTATE error code for the last error thread_id - returns the thread ID for the current connection warning_count - returns the number of warnings generated during execution of the previous SQL statement
<classname>mysqli_stmt</classname> Represents a prepared statement.
&reftitle.methods; bind_param - binds variables to a prepared statement bind_result - binds variables to a prepared statement for result storage close - closes a prepared statement data_seek - seeks to an arbitrary row in a statement result set execute - executes a prepared statement fetch - fetches result from a prepared statement into bound variables free_result - frees stored result memory for the given statement handle prepare - prepares a SQL query reset - resets a prepared statement result_metadata - retrieves a resultset from a prepared statement for metadata information send_long_data - sends data in chunks store_result - buffers complete resultset from a prepared statement
&reftitle.properties; affected_rows - returns affected rows from last statement execution errno - returns errorcode for last statement function error - returns errormessage for last statement function field_count - returns the number of columns in a result set id - returns the statement identifier insert_id - returns the value generated for an AUTO_INCREMENT column by the prepared statement num_rows - returns the number of rows in the result set param_count - returns number of parameter for a given prepare statement sqlstate - returns a string containing the SQLSTATE error code for the last statement function
<classname>mysqli_result</classname> Represents the result set obtained from a query against the database.
&reftitle.methods; close - closes resultset data_seek - moves internal result pointer fetch_array - fetches a result row as an associative array, a numeric array, or both. fetch_assoc - fetches a result row as an associative array fetch_field - gets column information from a resultset fetch_fields - gets information for all columns from a resulset fetch_field_direct - gets column information for specified column fetch_object - fetches a result row as an object fetch_row - gets a result row as an enumerated array field_seek - set result pointer to a specified field offset free_result - frees result memory
&reftitle.properties; current_field - returns offset of current fieldpointer field_count - returns number of fields in resultset lengths - returns an array of columnlengths num_rows - returns number of rows in resultset type - returns MYSQLI_STORE_RESULT or MYSQLI_USE_RESULT
&reference.mysqli.constants;
Examples All Examples in the MySQLI documentation use the world database from MySQL AB. The world database can be found at &url.mysql.example;
&reference.mysqli.functions;