HOW THE QUIZ WORKS:
Clicking the ‘randomize’ button situated above the reference table generates a new table whereby the function descriptions, function syntaxes, and function return values are randomized. The quiz involves matching the function descriptions, function syntaxes, and function return values to the correct function name. Information relating to the randomization of table cells will be displayed for three seconds, before disappearing.
On a desktop computer, table elements are selected by left-clicking the desired table cell and holding the left click in the mouse down position for one second before releasing the left click. The text inside the table cell will turn red to indicate that the one-second mouse left-click has successfully selected a table cell. To then swap the selected table cell with the target table cell, simply repeat the one-second left mouse-click process on the target cell; the table cells will swap position. To de-select a table cell, simply repeat the one-second left mouse-click process on the original table cell.
To select a table element on a touchscreen device (mobile, tablet), simply touch the desired table cell and maintain the touch for one second before removing your finger from the screen. The text inside the table cell will turn red to indicate that the one-second touch has successfully selected a table cell. To then swap the selected table cell with the target table cell, simply repeat the one-second touch process on the target cell; the table cells will swap position. To de-select a table cell, simply repeat the one-second touch process on the original table cell.
Normal touchscreen scrolling behaviour is exhibited by the cells with a light green background; cells without a light green background will not respond to normal touchscreen scrolling. The table is positioned in such a way that the user can also initiate touchscreen scrolling by swiping to the right or left of the table.
When a row consists of the correct function name, function description, function syntax, and function return value, the background colour of the row will change from ‘transparent’ to ‘khaki’; this provides visual feedback that the row is complete.
Once the entire table is complete, a paragraph of feedback will congratulate the user and provide the following information: date and time of quiz commencement; date and time of quiz completion; and the length of time it took the user to complete the quiz.
VIEWPORT OPTIONS:



PURPOSE:
This webpage serves two purposes:
- It provides a reference table for the PHP MySQLi functions, with information extracted and condensed from w3schools.com and php.net.
- It enables users to complete a quiz related to the PHP MySQLi functions.
USAGE:
For each PHP MySQLi function there are four table cells of information: the function name; the function description; the function syntax; and the function return value. There are three layouts available – ‘mobile‘, ‘tablet‘, and ‘desktop‘.
Click the relevant button below to display the PHP MySQLi functions reference table, sized appropriately for the desired viewport. A ‘RANDOMIZE‘ button appears above the reference table once the viewport is selected; clicking this button facilitates the commencement of a quiz.
Click the ‘RANDOMIZE‘ button to randomize the functional descriptions, the functional syntaxes, and the functional return information.
FUNCTION NAME | FUNCTION DESCRIPTION | FUNCTION SYNTAX | FUNCTION RETURN VALUE |
---|---|---|---|
mysqli::$affected_rows() mysqli_affected_rows()
[mysqli::$affected_rows — mysqli_affected_rows – Gets the number of affected rows in a previous MySQL operation] |
This function returns the number of rows affected by the last INSERT , UPDATE , REPLACE , or DELETE query. For SELECT statements, this function works like mysqli_num_rows() . |
Object-oriented style:$mysqli->affected_rows;
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::$affected_rows() : returns an integer — an integer greater than 0 represents the number of rows affected or retrieved; 0 indicates that no records were updated for an UPDATE statement, no rows matched the WHERE clause in the query, or that no query has yet been executed; and -1 indicates that the query returned an error. If the number of affected rows exceeds PHP_INT_MAX, the number of affected rows will be returned as a string. |
mysqli::autocommit() mysqli_autocommit()
[mysqli::autocommit — mysqli_autocommit – Turns on or off auto-committing database modifications] |
This function turns on or off auto-commit mode on queries for the database connection. The current state of autocommit can be determined by using the SQL command SELECT @@autocommit . This function does not work for non-transactional tables like MyISAM and ISAM. |
Object-oriented style:$mysqli->autocommit(mode);
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::autocommit() : returns TRUE on success; FALSE on failure. |
mysqli::begin_transaction() mysqli_begin_transaction()
[mysqli::begin_transaction — mysqli_begin_transaction – Starts a transaction] |
This function begins a MySQL transaction. It requires the InnoDB engine for successful operation. | Object-oriented style:$mysqli->begin_transaction(flags [optional parameter, with a default value of 0], name [optional parameter]);
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::begin_transaction() : returns TRUE on success; FALSE on failure. |
mysqli::change_user() mysqli_change_user()
[mysqli::change_user — mysqli_change_user – Changes the user of the specified database connection] |
This function sets the current database and changes the user of the specified database connection. If an invalid username or password is specified – or if the user does not have sufficient permissions to access the specified database – then authorization will fail and the current user authentication will remain. This command will always cause the database connection to behave as if it were an entirely new database connection, regardless of whether the operation was successfully completed: any active transactions are rolled back; any temporary tables are closed; and all locked tables are unlocked. |
Object-oriented style:$mysqli->change_user(user, password, database);
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::change_user() : returns TRUE on success; FALSE on failure. |
mysqli::character_set_name() mysqli_character_set_name()
[mysqli::character_set_name — mysqli_character_set_name – Returns the default character set for the database connection] |
This function returns the current character set for the database connection. | Object-oriented style:$mysqli->character_set_name();
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::character_set_name() : returns the default character set for the current connection. |
mysqli::close() mysqli_close()
[mysqli::close — mysqli_close – Closes a previously opened database connection] |
This function closes a previously opened database connection. Explicitly closing open database connections and freeing result sets is optional; when a PHP script finishes execution, open non-persistent MySQL connections and result sets are automatically destroyed. However, doing so is recommended, since performance-improving resources are immediately returned to PHP and MySQL. This function will not close persistent connections. | Object-oriented style:$mysqli->close();
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::close() : returns TRUE on success; FALSE on failure. |
mysqli::commit() mysqli_commit()
[mysqli::commit — mysqli_commit – Commits the current transaction] |
This function commits the current transaction for the specified database connection. | Object-oriented style:$mysqli->commit(flags [optional parameter with a default value of 0], name [optional parameter]);
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::commit() : returns TRUE on success; FALSE on failure. |
mysqli::$connect_errno() mysqli_connect_errno()
[mysqli::$connect_errno — mysqli_connect_errno() – Returns the error code from last connect call] |
This function returns the last error code [‘number’/‘no’] from the last call to mysqli_connect() . The MySQL header file errmsg.h lists client error message numbers; the MySQL file mysqld_error.h lists server error message numbers. The file Docs/mysqld_error.txt in the MySQL source distribution details a complete list of error message numbers and error messages. |
Object-oriented style:$mysqli->connect_errno;
Procedural style: |
mysqli::$connect_errno : returns an error code value for the last call to mysqli_connect() . A return value of 0 means that no error occurred. |
mysqli::$connect_error() mysqli_connect_error()
[mysqli::$connect_error — mysqli_connect_error – Returns a string description of the last connect error] |
This function returns the last error message string from the last call to mysqli_connect() . |
Object-oriented style:$mysqli->connect_error;
Procedural style: [The object-oriented syntax works as of PHP 5.2.9+; use the procedural style for compatibility with earlier versions of PHP.] |
mysqli::$connect_error() : returns a string description of the error. NULL is returned if no error occurred. |
mysqli::__construct() mysqli::connect() mysqli_connect()
[mysqli::__construct — mysqli::connect — mysqli_connect – Open a new connection to the MySQL server] |
This function opens a connection to the MySQL server. The function parameters can be described as follows: host: either a host name or an IP address — the function assumes the local host if the NULL value or the string “localhost” is passed — pipes will be used in preference to the TCP/IP protocol where practicable — a persistent connection is created by prefixing host with p: — connections from the connection pool automatically invoke mysqli_change_user() ; username: specifies the MySQL user name; password: the MySQL server attempts to authenticate the user against those user records which have no password if password is not provided/NULL — thus, one username can be used with varying permissions, depending on if password is provided or not; database: specifies the default database to be used when performing queries, if provided; port: specifies the port number to attempt to connect to the MySQL server, if provided; and socket: specifies the socket or named pipe that should be used — how the connection is made to the MySQL server is determined by the host parameter. |
Object-oriented style – flavour one:mysqli::__construct(host [optional parameter, with a default value of ini_get(“mysqli.default_host”)], username [optional parameter, with a default value of ini_get(“mysqli.default_user”)], password [optional parameter, with a default value of ini_get(“mysqli.default_pw”)], database [optional parameter, with a default value of “”], port [optional parameter, with a default value of ini_get(“mysqli.default_port”)], socket [optional parameter, with a default value of ini_get(“mysqli.default_socket”)]);
Object-oriented style – flavour two: Procedural style: |
mysqli::__construct() : returns an object representing a connection to the MySQL server. |
mysqli::debug() mysqli_debug()
[mysqli::debug — mysqli_debug – Performs debugging operations] |
This function performs debugging operations using the Fred Fish debugging library. The MySQL client library must be compiled to support debugging in order to use this function. | Object-oriented style:mysqli->debug(message);
Procedural style: [message: a string representation of the debugging operation to perform.] |
mysqli::debug() : returns TRUE. |
mysqli::dump_debug_info() mysqli_dump_debug_info()
[mysqli::dump_debug_info — mysqli_dump_debug_info – Dump debugging information into the log] |
This function is used to dump connection-related debugging information into the MySQL Server log. mysqli::dump_debug_info() is designed to be invoked by a user with the SUPER privilege. |
Object-oriented style:$mysqli->dump_debug_info();
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::dump_debug_info() : returns TRUE on success; FALSE on failure. |
mysqli::$errno() mysqli_errno()
[mysqli::$errno — mysqli_errno – Returns the error code for the most recent function call] |
This function returns the last error code [‘number’/‘no’] for the most recent MySQLi function call that can succeed or fail. The MySQL header file, errmsg.h , contains a list of client error message numbers; mysqld_error.h lists server error message numbers. A complete list of error message numbers and error messages can be found in the file Docs/mysqld_error.txt of the MySQL source distribution. |
Object-oriented style:$mysqli->errno;
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::$errno() : returns an error code value for the last function call, if it failed.A return value of 0 means no error occurred. |
mysqli::$error_list() mysqli_error_list()
[mysqli::$error_list — mysqli_error_list – Returns a list of errors from the last command executed] |
This function returns an array [‘list’] of errors pertaining to the last MySQLi function call that can succeed or fail. | Object-oriented style:$mysqli->error_list;
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::$error_list() : returns a list of errors, each as an associative array containing the errno, error, and sqlstate. |
mysqli::$error() mysqli_error()
[mysqli::$error — mysqli_error – Returns a string description of the last error] |
This function returns the last error message for the most recent MySQLi function call that can succeed or fail. | Object-oriented style:$mysqli->error;
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::$error() : returns a string that describes the error or an empty string if no error occurred. |
mysqli::$field_count() mysqli_field_count()
[mysqli::$field_count — mysqli_field_count – Returns the number of columns for the most recent query] |
This function returns the number [‘count’] of columns [‘fields’] for the most recent query on the connection represented by $mysqli /mysqli_link . This function can be useful to determine whether a query should have produced a non-empty result set – without knowing the nature of the query – when working with the mysqli_store_result() function. |
Object-oriented style:$mysqli->field_count;
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::$field_count() : returns an integer representation of the number of fields in a result set. |
mysqli::get_charset() mysqli_get_charset()
[mysqli::get_charset — mysqli_get_charset – Returns a character set object] |
This function returns [‘gets’] a character set object, providing several properties of the current, active character set. | Object-oriented style:$mysqli->get_charset();
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::get_charset() : returns a character set object with the following properties: charset [character set name]; collation [collation name]; dir [directory the charset was fetched from, or “” for built-in character sets]; min_length [minimum character length in bytes]; max_length [maximum character length in bytes]; number [internal character set number]; and state [character set status]. |
mysqli::$client_info() mysqli::get_client_info() mysqli_get_client_info()
[mysqli::$client_info — mysqli::get_client_info — mysqli_get_client_info – Get MySQL client info] |
This function returns [‘gets’] a string representation [‘info’] of the MySQL client library version. | Object-oriented style – flavour one:$mysqli->client_info;
Object-oriented style – flavour two: Procedural style: [mysqli_link: a link identifier returned by |
mysqli::get_client_info() : returns a string representation of the MySQL client library version. |
mysqli::$client_version() mysqli_get_client_version()
[mysql::$client_version — mysqli_get_client_version – Returns the MySQL client version as an integer] |
This function returns (‘gets’) the MySQL client version number as an integer. It is useful in situations where you need to quickly know if some capability exists. | Object-oriented style:$mysqli->client_version;
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::$client_version() : returns a number that represents the MySQL client library version in the following format: [main_version * 10000 + minor_version * 100 + sub_version ]. |
mysqli::get_connection_stats() mysqli_get_connection_stats()
[mysqli::get_connection_stats — mysqli_get_connection_stats – Returns statistics about the client connection] |
This function returns (‘gets’) statistics (‘stats’) about the client connection. It is only available with mysqlnd . |
Object-oriented style:$mysqli->get_connection_stats();
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::get_connection_stats() : returns an array with connection stats on success; FALSE on failure. The array consists of approximately 120 elements, ranging from bytes_sent to proto_binary_fetched_other. |
mysqli::$host_info() mysqli_get_host_info()
[mysqli::$host_info — mysqli_get_host_info – Returns a string representing the type of connection used] |
This function returns a string describing (‘giving information about’) the connection represented by $mysqli [object-oriented]/mysqli_link [procedural] (including the server host name). | Object-oriented style:$mysqli->host_info;
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::$host_info() : returns a character string representing the server hostname and the connection type. |
mysqli::$protocol_version() mysqli_get_proto_version()
[mysqli::$protocol_version — mysqli_get_proto_version – Returns the version of the MySQL protocol used] |
This function returns an integer representation of the MySQL protocol version used by the connection represented by the $mysqli [object-oriented]/mysqli_link [procedural] parameter. | Object-oriented style:$mysqli->protocol_version;
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::$protocol_version() : returns an integer representation of the protocol version. |
mysqli::$server_info() mysqli::get_server_info() mysqli_get_server_info()
[mysqli::$server_info — mysqli::get_server_info — mysqli_get_server_info – Returns the version of the MySQL server] |
This function returns a string representation of [‘information about’] the MySQL server version that the MySQLi extension is connected to. | Object-oriented style – flavour one:$mysqli->server_info;
Object-oriented style – flavour two: Procedural style: [mysqli_link: a link identifier returned by |
mysqli::$server_info() : returns a character string representing the MySQL server version. |
mysqli::$server_version() mysqli_get_server_version()
[mysqli::$server_version — mysqli_get_server_version – Returns the version of the MySQL server as an integer] |
This function returns the version of the server connected to [represented by $mysqli (object-oriented style) / mysqli_link (procedural style)] as an integer. | Object-oriented style:$mysqli->server_version;
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::$server_version() : returns an integer representation of the MySQL server version. This integer representation takes the following form: main_version * 10000 + minor_version * 100 + sub_version (thus, version 4.1.0 is returned as 40100). |
mysqli::get_warnings() mysqli_get_warnings()
[mysqli::get_warnings — mysqli_get_warnings – Get result of SHOW WARNINGS] |
This function returns [‘gets’] an array of mysqli warnings. Each warning object has three properties: message , sqlstate , and errno . The array can be traversed using the next() function of the mysqli_warning class. |
Object-oriented style:$mysqli->get_warnings();
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::get_warnings() : returns an array of mysqli warning objects; this array can be navigated using the next() function of the mysqli_warning class. |
mysqli::$info() mysqli_info()
[mysqli::$info — mysqli_info – Retrieves information about the most recently executed query] |
This function returns an informative string about the most recently executed mysqli query. For queries of the form INSERT INTO...SELECT /INSERT INTO...VALUES (...),(...),(...) /ALTER TABLE... , the returned string is of the form Records: #, Duplicates: #, Warnings: #. Where the query is of the form LOAD DATA INFILE... , the returned string is of the form Records: #, Deleted: #, Skipped: #, Warnings: #. For queries of the form UPDATE... , the returned string is of the form Rows Matched: #, Changed: #, Warnings: #. |
Object-oriented style:$mysqli->info;
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::$info() : returns a character string representing additional information about the most recently executed query. Queries that are not of the form INSERT INTO...SELECT / INSERT INTO...VALUES (...),(...),(...) / ALTER TABLE... / LOAD DATA INFILE... / UPDATE... are not supported, and will return an empty string. |
mysqli::init() mysqli_init()
[mysqli::init — mysqli_init – Initializes MySQLi and returns a resource for use with mysqli_real_connect()] |
This function allocates or initializes a MySQL object suitable for use in conjunction with the mysqli_options() and mysqli_real_connect() functions. With the exception of mysqli_options() , subsequent calls to any MySQLi function will fail until mysqli_real_connect() is called. |
Object-oriented style:$mysqli->init();
Procedural style: |
mysqli::init() : returns a MySQL object. |
mysqli::$insert_id() mysqli_insert_id()
[mysqli::$insert_id — mysqli_insert_id – Returns the auto generated ID used in the latest query] |
This function returns the ID generated by a query (usually INSERT ) on a table with a column having the AUTO INCREMENT attribute. If no INSERT or UPDATE statements were sent via this connection, or if the modified table does not have a column with the AUTO-INCREMENT property, this function returns 0. |
Object-oriented style:$mysqli->insert_id;
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::$insert_id() : returns the value of the AUTO_INCREMENT field that was updated by the previous query. Returns zero if the query did not update an AUTO_INCREMENT field, or if there was no previous query on the connection. If the maximal int value is exceeded, a string will be returned instead. |
mysqli::kill() mysqli_kill()
[mysqli::kill — mysqli_kill – Asks the server to kill a MySQL thread] |
This function is used to ask the server to kill a MySQL thread. The processid parameter specifies which MySQL thread to kill. The processid value must be obtained by calling the mysqli_thread_id() function. The SQL command KILL QUERY processid should be used to stop a running query. |
Object-oriented style:$mysqli->kill(processid);
Procedural style: [processid: specifies which MySQL thread to kill. |
mysqli::kill() : returns TRUE on success; FALSE on failure. |
mysqli::more_results() mysqli_more_results()
[mysqli::more_results — mysqli_more_results – Check if there are any more query results from a multi query] |
This function is used to indicate if one or more result sets are available from a previous call to mysqli_multi_query() . |
Object-oriented style:$mysqli->more_results();
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::more_results() : returns TRUE if one or more result sets are available from a previous call to mysqli_multi_query() ; otherwise FALSE. |
mysqli::multi_query() mysqli_multi_query()
[mysqli::multi_query — mysqli_multi_query – Performs a query on the database] |
This function executes one or multiple quer[y]ies which are concatenated by a semicolon. The functions mysqli_use_result() or mysqli_store_result() must be used to retrieve the result set of the first query; the mysqli_more_results() and mysqli_next_result() functions are used to process subsequent queries. |
Object-oriented style:$mysqli->multi_query(query);
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::multi_query() : returns TRUE on success; FALSE if the first query failed — in which case, you have to call mysqli_next_result() to obtain errors from subsequent statements. |
mysqli::next_result() mysqli_next_result()
[mysqli::next_result — mysqli_next_result – Prepare next result from multi_query] |
This function prepares the next result set from a previous call to mysqli_multi_query() , retrievable via the use of mysqli_store_result() or mysqli_use_result() . |
Object-oriented style:$mysqli->next_result();
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::next_result() : returns TRUE on success; FALSE on failure. |
mysqli::options() mysqli_options()
[mysqli::options — mysqli_options – Set options] |
This function is used to set extra connect options and affect behaviour for a connection. In order to set multiple options, this function can be called several times. mysqli_options() should be called after mysqli_init() but before mysqli_real_connect() . |
Object-oriented style:$mysqli->options(option, value);
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::options() : returns TRUE on success; FALSE on failure. MySQLnd always assumes the server default charset, sent during connection ‘handshake’/authentication. Libmysqlclient uses the default charset set in the my.cnf or via an explicit call to mysqli_options() between the invocations of mysqli_real_connect() and mysqli_init() . |
mysqli::ping() mysqli_ping()
[mysqli::ping — mysqli_ping – Pings a server connection, or tries to reconnect if the connection has gone down] |
This function pings a server connection in order to check whether the connection to the server is working. This function is useful for clients that remain idle for a long while, in order to check whether the server has closed the connection and reconnect if necessary. If the connection has gone down and the php.ini global option mysqli.reconnect is set up, an automatic reconnection is attempted unless the mysqlnd driver is in use [in which case, reconnection is not automatically attempted]. |
Object-oriented style:$mysqli->ping();
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::ping() : returns TRUE on success; FALSE on failure. |
mysqli::poll() mysqli_poll()
[mysqli::poll — mysqli_poll – Poll connections] |
This function – only available with mysqlnd – is used to poll connections. It can be used as a static method. |
Object-oriented style:$mysqli->poll(read, error, reject, sec, usec [optional parameter, with a default value of 0]);
Procedural style: [read: a list of connections to check for outstanding results that can be read; error: a list of connections on which an error occurred [for example, lost connection or query failure]; reject: a list of connections rejected because no asynchronous query has been run for which the function could poll results; sec: a non-negative representation of the maximum seconds to wait; and usec: the maximum, non-negative number of microseconds to wait.] |
mysqli::poll() : returns the number of ready connections on success; FALSE on failure. |
mysqli::prepare() mysqli_prepare()
[mysqli::prepare — mysqli_prepare – Prepare an SQL statement for execution] |
This function prepares the SQL query, and returns a statement handle for use in further operations on the statement. The query must consist of a single SQL statement. Before executing the statement, parameter markers must be bound to application variables using mysql_stmt_bind_param() ; before fetching rows, parameter markers must be bound to application variables using mysql_stmt_bind_result() . |
Object-oriented style:$mysqli->prepare(query);
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::prepare() : returns a statement object on success; FALSE on failure. |
mysqli::query() mysqli_query()
[mysqli::query — mysqli_query – Performs a query on the database] |
This function performs a query against the database. For queries that are not of the form INSERT / UPDATE / DELETE [i.e. non-DML queries], this function is similar to calling mysqli_real_query() followed by either mysqli_use_result() or mysqli_store_result() . |
Object-oriented style:$mysqli->query(query, result_mode [optional parameter, with a default value of MYSQLI_STORE_RESULT]);
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::query() : returns a mysqli_result object on successful SELECT / SHOW / DESCRIBE / EXPLAIN queries. TRUE is returned for other successful queries. FALSE is returned on failure. |
mysqli::real_connect() mysqli_real_connect()
[mysqli::real_connect — mysqli_real_connect – Opens a connection to a mysql server] |
This function establishes a connection to a MySQL database engine. This function differs from mysqli_connect() in the following ways: mysqli_real_connect() needs a real, valid object that has to be created by mysqli_init() ; various connection options can be set using mysqli_options() ; and there is a flags parameter. |
Object-oriented style:$mysqli->real_connect(host, username, password, database, port, socket, flags);
Procedural style: [ALL PARAMETERS – barring the procedural mysqli_link argument – ARE OPTIONAL. mysqli_link: a link identifier returned by |
mysqli::real_connect() : returns TRUE on success; FALSE on failure. Available options for the flags parameter are: MYSQLI_CLIENT_COMPRESS; MYSQLI_CLIENT_FOUND_ROWS; MYSQLI_CLIENT_IGNORE_SPACE; MYSQLI_CLIENT_INTERACTIVE; MYSQLI_CLIENT_SSL; and MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT [only for installations using MySQL Native Driver and MySQL 5.6+]. |
mysqli::real_escape_string() mysqli::escape_string() mysqli_real_escape_string()
[mysqli::real_escape_string — mysqli::escape_string — mysqli_real_escape_string – Escapes special characters in a string for use in an SQL statement, taking into account the current charset of the connection] |
This function is used to create a legal (‘real’) SQL string, suitable for use in an SQL statement. escape_string is encoded to an escaped string, taking into account the current character set of the connection. | Object-oriented style – flavour one:$mysqli->real_escape_string(escape_string);
Object-oriented style – flavour two: Procedural style: [mysqli_link: a link identifier returned by |
mysqli::real_escape_string() : returns an escaped string. The character set must be defined either at the server level, or with the API function mysqli_set_charset() for it to affect mysqli_real_escape_string() . E_WARNING-level errors will be emitted – and NUL will be returned – if a valid MySQLi connection is not passed in. |
mysqli::real_query() mysqli_real_query()
[mysqli::real_query — mysqli_real_query – Execute an SQL query] |
This function really executes a single query against the database. The result of the query can then be retrieved using mysqli_store_result() or used via mysqli_use_result() . |
Object-oriented style:$mysqli->real_query(query);
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::real_query : returns TRUE on success; FALSE on failure. |
mysqli::reap_async_query() mysqli_reap_async_query()
[mysqli::reap_async_query — mysqli_reap_async_query – Get result from async query] |
This function – only available with mysqlnd – is used to get (‘reap’) the result from an async query. | Object-oriented style:$mysqli->reap_async_query();
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::reap_async_query : returns a mysqli_result on success; FALSE on failure. |
mysqli::refresh() mysqli_refresh()
[mysqli::refresh — mysqli_refresh – Refreshes] |
This function flushes tables and caches, or resets [generally ‘refreshes’] the replication server information. | Object-oriented style:$mysqli->refresh(options);
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::refresh : returns TRUE if the refresh was a success; FALSE otherwise. |
mysqli::release_savepoint() mysqli_release_savepoint()
[mysqli::release_savepoint — mysqli_release_savepoint – Removes the named savepoint from the set of savepoints of the current transaction] |
This function – not currently documented in the official literature available at php.net – removes [‘releases’] savepoint from the set of savepoints of the current transaction. | Object-oriented style:$mysqli->release_savepoint(savepoint);
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::release_savepoint() : returns TRUE on success; FALSE otherwise. |
mysqli::rollback() mysqli_rollback()
[mysqli::rollback — mysqli_rollback – Rolls back current transaction] |
This function rolls back the current transaction for the database. | Object-oriented style:$mysqli->rollback(flags [optional parameter, with a default value of 0], name [optional parameter]);
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::rollback() : returns TRUE on success; FALSE otherwise. |
mysqli::rpl_query_type() mysqli_rpl_query_type()
[mysqli::rpl_query_type — mysqli_rpl_query_type – Returns RPL query type] |
This function – deprecated and removed as of PHP 5.3.0 and not currently documented by the literature at php.net – returns an integer representation of one of the following constants: MYSQLI_RPL_MASTER [e.g. for INSERT / UPDATE queries]; MYSQLI_RPL_SLAVE [e.g. for SELECT queries]; or MYSQLI_RPL_ADMIN [e.g. FLUSH / REPAIR ] depending on the query type. |
Object-oriented style:$mysqli->rpl_query_type(query);
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::rpl_query_type() : returns an integer representation of a named query type constant. |
mysqli::savepoint() mysqli_savepoint()
[mysqli::savepoint — mysqli_savepoint – Set a named transaction savepoint] |
This function – not currently documented by the literature at php.net – sets a named transaction savepoint. | Object-oriented style:$mysqli->savepoint(savepoint);
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::savepoint() : returns TRUE on success; FALSE on failure. |
mysqli::select_db() mysqli_select_db()
[mysqli::select_db — mysqli_select_db – Selects the default database for database queries] |
This function – used to change the default database for the connection – selects the default database to be used when performing queries against the database connection. The default database is initially specified via the fourth parameter of the mysqli_connect() function. |
Object-oriented style:$mysqli->select_db(database);
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::select_db() : returns TRUE on success; FALSE on failure. |
mysqli::send_query() mysqli_send_query()
[mysqli::send_query — mysqli_send_query – Send the query and return] |
This function – deprecated as of PHP 5.3.0 and not documented in the literature at php.net – is presumably used to send the query and return. | Object-oriented style:$mysqli->send_query(query);
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::send_query() : returns TRUE on success; FALSE on failure. |
mysqli::set_charset() mysqli_set_charset()
[mysqli::set_charset — mysqli_set_charset – Sets the default client character set] |
This function sets the default character set to be used when sending information to and from the database server. This is the preferred way to change the charset; using mysqli_query('SET NAMES utf8'); is not recommended. |
Object-oriented style:$mysqli->set_charset(charset);
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::set_charset() : returns TRUE on success; FALSE on failure. To use this function on Windows you must use MySQL client library version 4.1.11+; for MySQL 5.0 you need 5.0.6+. |
mysqli::set_local_infile_default() mysqli_set_local_infile_default()
[mysqli::set_local_infile_default — mysqli_set_local_infile_default – Unsets user defined handler for load local infile command] |
This function restores [‘sets’] the local infile default handler; the LOAD DATA INFILE LOCAL handler previously set with mysqli_set_local_infile_handler() is deactivated. |
Object-oriented style:$mysqli->set_local_infile_default();
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::set_local_infile_default() : no value is returned. |
mysqli::set_local_infile_handler() mysqli_set_local_infile_handler()
[mysqli::set_local_infile_handler — mysqli_set_local_infile_handler – Set callback function for LOAD DATA LOCAL INFILE command] |
This function sets the callback function [‘handler’] for the LOAD DATA LOCAL INFILE command. The callback‘s task is to read input from the file specified in the LOAD DATA LOCAL INFILE and to reformat it into the format understood by LOAD DATA INFILE . The returned data needs to match the format specified in the LOAD DATA . |
Object-oriented style:$mysqli->set_local_infile_handler(callback_function);
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::set_local_infile_handler() : returns TRUE on success; FALSE on failure. |
mysqli::$sqlstate() mysqli_sqlstate()
[mysqli::$sqlstate — mysqli_sqlstate -Returns the SQLSTATE error from previous MySQL operation] |
This function returns a string containing the SQLSTATE error code for the last error. Five characters comprise the error code; ‘00000’ means no error.The values are specified by ANSI SQL and ODBC. Not all MySQL errors are mapped to SQLSTATE s; the general error value HY000 is used for unmapped errors. |
Object-oriented style:$mysqli->sqlstate;
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::sqlstate() : returns a 5-character string containing the SQLSTATE error code for the last error. A list of possible values is available at: http://dev.mysql.com/doc/mysql/en/error-handling.html. |
mysqli::ssl_set() mysqli_ssl_set()
[mysqli::ssl_set — mysqli_ssl_set – Used for establishing secure connections using SSL] |
This function is used for establishing [‘setting’] secure connections using SSL. It must be called before mysqli_real_connect() and is only effective if OpenSSL support is enabled. MySQL Native Driver only supports SSL from PHP 5.3.3+; MySQL Native Driver is enabled by default on Windows platforms from PHP 5.3+. |
Object-oriented style:$mysqli->ssl_set(key, cert, ca, capath, cipher);
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::ssl_set() : always returns TRUE. If SSL setup is incorrect, mysqli_real_connect() will return an error when you try to connect. |
mysqli::stat() mysqli_stat()
[mysqli::stat — mysqli_stat – Gets the current system status] |
This function returns a string containing information relating to the system status, similar to that provided by the mysqladmin status command.The following elements are returned in the string: ‘Uptime’; ‘Threads’; ‘Questions’; ‘Slow queries’; ‘Opens’; ‘Flush tables’; ‘Open tables’; ‘Queries per second avg’; ‘Memory in use’; ‘Max memory used’. |
Object-oriented style:$mysqli->stat();
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::stat() : returns a string containing the server status on success; FALSE on failure. A description of the intra-string elements: ‘Uptime’ – the number of seconds that the MySQL server has been running; ‘Threads’ – the number of active threads [clients]; ‘Questions’ – the number of questions from clients since the server was started; ‘Slow queries’ – the number of queries that have taken longer than long_query_time seconds; ‘Opens’ – the number of tables the server has opened; ‘Flush tables’ – the number of flush-* , refresh , and reload commands the server has executed; ‘Open tables’ – the number of tables currently open; ‘Queries per second avg’ – Questions divided by Uptime; and the two self-explanatory elements ‘Memory in use’ and ‘Max memory used’. |
mysqli::stmt_init() mysqli_stmt_init()
[mysqli::stmt_init — mysqli_stmt_init – Initializes a statement and returns an object for use with |
This function allocates and initializes a statement object suitable for use with mysqli_stmt_prepare() . All subsequent calls to any mysqli_stmt...() function will fail until mysqli_stmt_prepare() is called. |
Object-oriented style:$mysqli->stmt_init();
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::stmt_init() : returns a mysqli statement object. |
mysqli::store_result() mysqli_store_result()
[mysqli::store_result — mysqli_store_result – Transfers a result set from the last query] |
This function transfers the (stored) result set from the last query on the database connection represented by $mysqli [‘object-oriented’ style] / mysqli_link [‘procedural’ style]; the result set can then be used with the mysqli_data_seek() function.When transferring large result sets it is particularly important to free the memory used to store a result set using mysqli_free_result() . |
Object-oriented style:$mysqli->store_result(option [optional parameter]);
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::store_result() : returns a buffered result object on success; FALSE on failure. FALSE is returned if: the query didn’t return a result set; the reading of the result set failed; or sufficient memory for an excessively large result set cannot be allocated. If mysqli_field_count() returns a non-zero value, the statement should have produced a non-empty result set; similarly, if mysqli_error() returns an empty string – or mysqli_errno() returns zero – then no error has occurred. |
mysqli::$thread_id() mysqli_thread_id()
[mysqli::$thread_id — mysqli_thread_id – Returns the thread ID for the current connection] |
This function returns the thread ID for the current connection; the thread can then be killed using the mysqli_kill() function. The thread ID is assigned on a per-connection basis; if the connection is broken and then re-established (for example, by using mysqli_ping() ) a new thread ID will be assigned. Thus, the thread ID should be obtained only when necessary for immediate use. A running query can be killed using the SQL command KILL QUERY processid . |
Object-oriented style:$mysqli->thread_id;
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::$thread_id() : returns the thread ID for the current connection as an integer. |
mysqli::thread_safe() mysqli_thread_safe()
[mysqli::thread_safe — mysqli_thread_safe – Returns whether thread safety is given or not] |
This function is used to determine whether the client library is compiled as thread-safe. | Object-oriented style:$mysqli->thread_safe();
Procedural style: |
mysqli::thread_safe() : returns TRUE if the client library is thread-safe; FALSE otherwise. |
mysqli::use_result() mysqli_use_result()
[mysqli::use_result — mysqli_use_result – Initiate a result set retrieval] |
This function is used to initiate the retrieval of a result set from the last mysqli_real_query() function execution on the connection. This function – or mysqli_store_result() – must be called before the results of a query can be retrieved; one or the other function must be called to stop the next query on the database connection failing. mysqli_use_result() does not transfer the entire result set from the database, and thus cannot be used by functions such as mysqli_data_seek() to move to a particular row within a result set. |
Object-oriented style:$mysqli->use_result();
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::use_result() : returns an unbuffered mysqli result object on success; FALSE on failure. This function should not be used if a lot of processing is performed on the client side, since this will tie up the server and prevent other threads updating the tables from which data is being fetched. |
mysqli::$warning_count() mysqli_warning_count()
[mysqli::$warning_count — mysqli_warning_count – Returns the number of warnings from the last query for the given link] |
This function returns the number (‘count’) of warnings from the last query in the connection. You can also use the SQL command SHOW WARNINGS [limit_row_count ] to retrieve warning messages. |
Object-oriented style:$mysqli->warning_count;
Procedural style: [mysqli_link: a link identifier returned by |
mysqli::warning_count() : returns the number of warnings; if no warnings were generated, 0 is returned. |
Forty-year-old father of three wonderful children [William, Seth, and Alyssa]. Works as an Assistant Technical Officer in the Sterile Services Department of Treliske Hospital, Cornwall. Enjoys jogging, web design, learning programming languages, and supporting Arsenal FC. Obtained a BA degree in English from the University of Bolton in 2008, and has continued to gain qualifications in a diverse range of subjects thereafter.
Leave a Reply