MENU
Query Functions
query($s [, $i=MYSQLI_STORE_RESULT]) performs a query $s. If $i=MYSQLI_USE_RESULT, all ensuing invocations will return the error ‘Commands out of sync’ unless free_result() is called, This function gives mysqli_result on success, or FALSE on failure. For non-DML queries (not INSERT, UPDATE or DELETE), it is similar to invoking real_query($s) followed by store_result() or use_result().\escape_string($s) encodes NUL, \n, \r, \, ‘, “, and Control-Z for use in an SQL statement.
refresh($i) updates caches or tables, or resets the replication server information. $i can be MYSQLI_ REFRESH_ {LOG | TABLES | HOSTS | STATUS | THREADS | SLAVE | MASTER}.
$affected_rows gives the no. of affected rows in a previous INSERT, UPDATE, REPLACE or DELETE operation. $field_count gives the no. of columns for the last query. $insert_id gives the AUTO_INCREMENTvalue changed by the previous query, or 0 if there was no previous query or if the query did not update an AUTO_INCREMENT value.
$info returns a string providing information about the last query.
Query type | Example result string |
INSERT INTO | Records:50 Duplicate:0 Warnings:0 |
LOAD DATA INFILE | Records:10 Duplicate:0 Warnings:0 |
ALER TABLE | Records:1 Deleted:0 Skipped:0 Warnings:0 |
UPDATE | Rows matched:30 Changed:30 Warnings:0 |
multi_query($s) runs multiple queries $s joined by ‘;’. To obtain the resultset from the first query you can use use_result() or store_result(). The queries after that can be processed using more_results() and next_result().
$errno gives the error code for the last function invocation. Zero means no error occurred.
$error gives a string describing the last error. An empty string is returned if there was no error.
$error_list gives a list of errors from the last executed command.
$sqlstate returns the SQLSTATE error string from the last operation. ‘00000’ means no error.
get_warnings() gets the result of SHOW WARNINGS.
$warning_count gives the no. of warnings from the most recent query.