MySQL Improved Extensionmysqli
&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;
mysqli
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 modificationschange_user - changes the user of the specified database connectioncharacter_set_name - returns the default character set for the database connectionclose - closes a previously opened connectioncommit - commits the current transactionconnect - opens a new connection to MySQL database serverdebug - performs debugging operationsdump_debug_info - dumps debug informationget_client_info - returns client versionget_host_info - returns type of connection usedget_server_info - returns version of the MySQL serverget_server_version - returns version of the MySQL serverinit - initializes mysqli objectinfo - retrieves information about the most recently executed querykill - asks the server to kill a mysql threadmulti_query - performs multiple queriesmore_results - check if more results exist from currently executed multi-querynext_result - reads next result from currently executed multi-queryoptions - set optionsping - pings a server connection or reconnects if there is no connectionprepare - prepares a SQL queryquery - performs a queryreal_connect - attempts to open a connection to MySQL database serverescape_string - escapes special characters in a string for use in a SQL statement, taking into account the current charset of the connectionrollback - rolls back the current transactionselect_db - selects the default databaseset_charset - sets the default client character setssl_set - sets ssl parametersstat - gets the current system statusstmt_init- initializes a statement for use with mysqli_stmt_preparestore_result - transfers a resultset from last querythread_safe - returns whether thread safety is given or notuse_result - transfers an unbuffered resultset from last query
&reftitle.properties;
affected_rows - gets the number of affected rows in a previous MySQL operationclient_info - returns the MySQL client version as a stringclient_version - returns the MySQL client version as an integererrno - returns the error code for the most recent function callerror - returns the error string for the most recent function callfield_count - returns the number of columns for the most recent queryhost_info - returns a string representing the type of connection usedinfo - retrieves information about the most recently executed queryinsert_id - returns the auto generated id used in the last queryprotocol_version - returns the version of the MySQL protocol usedserver_info - returns a string that represents the server version numberserver_version - returns the version number of the server as an integersqlstate - returns a string containing the SQLSTATE error code for the last errorthread_id - returns the thread ID for the current connectionwarning_count - returns the number of warnings generated during execution of the previous SQL statementmysqli_stmt
Represents a prepared statement.
&reftitle.methods;
bind_param - binds variables to a prepared statementbind_result - binds variables to a prepared statement for result storageclose - closes a prepared statementdata_seek - seeks to an arbitrary row in a statement result setexecute - executes a prepared statementfetch - fetches result from a prepared statement into bound variablesfree_result - frees stored result memory for the given statement handleprepare - prepares a SQL queryreset - resets a prepared statementresult_metadata - retrieves a resultset from a prepared statement for metadata informationsend_long_data - sends data in chunksstore_result - buffers complete resultset from a prepared statement
&reftitle.properties;
affected_rows - returns affected rows from last statement executionerrno - returns errorcode for last statement functionerror - returns errormessage for last statement functionfield_count - returns the number of columns in a result setid - returns the statement identifierinsert_id - returns the value generated for an AUTO_INCREMENT column by the prepared statementnum_rows - returns the number of rows in the result setparam_count - returns number of parameter for a given prepare statementsqlstate - returns a string containing the SQLSTATE error code for the last statement functionmysqli_result
Represents the result set obtained from a query against the database.
&reftitle.methods;
close - closes resultsetdata_seek - moves internal result pointerfetch_array - fetches a result row as an associative array, a numeric array, or both.fetch_assoc - fetches a result row as an associative arrayfetch_field - gets column information from a resultsetfetch_fields - gets information for all columns from a resulsetfetch_field_direct - gets column information for specified columnfetch_object - fetches a result row as an objectfetch_row - gets a result row as an enumerated arrayfield_seek - set result pointer to a specified field offsetfree_result - frees result memory
&reftitle.properties;
current_field - returns offset of current fieldpointerfield_count - returns number of fields in resultsetlengths - returns an array of columnlengthsnum_rows - returns number of rows in resultsettype - 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;