FUNCTION NAME |
FUNCTION DESCRIPTION |
FUNCTION SYNTAX |
FUNCTION RETURN VALUE |
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_multi_query(mysqli_link, query);
[mysqli_link: a link identifier returned by mysqli_connect() or mysqli_init() ; only required for the procedural style. query: the query, as a string; data inside the string should be properly escaped.] |
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_next_result(mysqli_link);
[mysqli_link: a link identifier returned by mysqli_connect() or mysqli_init() ; only required for the procedural style.] |
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_options(mysqli_link, option, value);
[mysqli_link: a link identifier returned by mysqli_connect() or mysqli_init() ; only required for the procedural style. option: defines the option that you want to set; can be any of MYSQLI_OPT_CONNECT_TIMEOUT , MYSQLI_OPT_LOCAL_INFILE , MYSQLI_INIT_COMMAND , MYSQLI_READ_DEFAULT_FILE , MYSQLI_READ_DEFAULT_GROUP , MYSQLI_SERVER_PUBLIC_KEY , MYSQLI_OPT_NET_CMD_BUFFER_SIZE , MYSQLI_OPT_NET_READ_BUFFER_SIZE , MYSQLI_OPT_INT_AND_FLOAT_NATIVE , and MYSQLI_OPT_SSL_VERIFY_SERVER_CERT . value: specifies the value for the chosen option.] |
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_ping(mysqli_link);
[mysqli_link: a link identifier returned by mysqli_connect() or mysqli_init() ; only required for the procedural style.] |
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:
mysqli_poll(read, error, reject, sec, usec [optional parameter, with a default value of 0]);
[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_prepare(mysqli_link, query);
[mysqli_link: a link identifier returned by mysqli_connect() or mysqli_init() ; only required for the procedural style. query: the query, as a string; no terminating semicolon or \g should be added to the statement. This parameter can include one or more parameter markers in the SQL statement by embedding question marks (?) at the appropriate places. There are restrictions on the usage of markers in SQL statements; broadly speaking, they are allowed in Data Manipulation Language statements [DML] but not in Data Definition Language statements [DDL].] |
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_query(mysqli_link, query, result_mode [optional parameter, with a default value of MYSQLI_STORE_RESULT]);
[mysqli_link: a link identifier returned by mysqli_connect() or mysqli_init() ; only required for the procedural style. query: the query string; data inside the query should be properly escaped. result_mode: either MYSQLI_USE_RESULT or MYSQLI_STORE_RESULT; if MYSQLI_USE_RESULT is used, all subsequent calls will issue a Commands out of sync error until mysqli_free_result() is called. MYSQLI_ASYNC – available with mysqlnd – makes it possible to perform the query asynchronously; mysqli_poll() is then used to get results from such queries.] |
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:
mysqli_query(mysqli_link, host, username, password, database, port, socket, flags);
[ALL PARAMETERS – barring the procedural mysqli_link argument – ARE OPTIONAL. mysqli_link: a link identifier returned by mysqli_connect() or mysqli_init() ; only required for the procedural style. host: either a host name or an IP address; the local host is assumed in response to the passing in of NULL or “localhost”; pipes – rather than the TCP/IP protocol – will be used where possible. username: the MySQL user name. password: if NULL, the MySQL server attempts to authenticate the user against those user records that have no associated password – thus, one user name can be used with different permissions, depending on whether a password was specified. database: specifies the default database to be used when performing queries. port: defines the port number on which to attempt connection with the SQL server. socket: specifies the socket or named pipe that should be used; the actual connection type is determined by the host parameter. flags: used to set different connection options.] |
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:
$mysqli->escape_string(escape_string);
Procedural style:
mysqli_real_escape_string(mysqli_link, escape_string);
[mysqli_link: a link identifier returned by mysqli_connect() or mysqli_init() ; only required for the procedural style. escape_string: the string to be escaped – the following characters are encoded: NUL [ASCII 0]; \n ; \r ; \ ; ' ; " ; and Control-Z .] |
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_real_query(mysqli_link, query);
[mysqli_link: a link identifier returned by mysqli_connect() or mysqli_init() ; only required for the procedural style. query: the query, as a string. Data inside the query should be properly escaped.] |
mysqli::real_query : returns TRUE on success; FALSE on failure. |