diff --git a/reference/mysqli/mysqli_driver/report-mode.xml b/reference/mysqli/mysqli_driver/report-mode.xml
index a024dcf205..22fbb8d05a 100644
--- a/reference/mysqli/mysqli_driver/report-mode.xml
+++ b/reference/mysqli/mysqli_driver/report-mode.xml
@@ -4,7 +4,7 @@
mysqli_driver::$report_modemysqli_report
- Enables or disables internal report functions
+ Sets mysqli error reporting mode
@@ -19,9 +19,12 @@
intflags
- A function helpful in improving queries during code development and testing.
- Depending on the flags, it reports errors from mysqli function calls or
- queries that don't use an index (or use a bad index).
+ Depending on the flags, it sets mysqli error reporting mode to exception, warning or none.
+ When set to MYSQLI_REPORT_ALL or MYSQLI_REPORT_INDEX
+ it will also inform about queries that don't use an index (or use a bad index).
+
+
+ The default setting is MYSQLI_REPORT_OFF.
@@ -79,7 +82,7 @@
&reftitle.returnvalues;
- &return.success;
+ Returns &true;.
@@ -91,35 +94,22 @@
report_mode = MYSQLI_REPORT_ALL;
try {
+ /* if the connection fails, a mysqli_sql_exception will be thrown */
+ $mysqli = new mysqli("localhost", "my_user", "my_password", "my_db");
/* this query should report an error */
$result = $mysqli->query("SELECT Name FROM Nonexistingtable WHERE population > 50000");
- /* this query should report a bad index */
+ /* this query should report a bad index if the column population doesn't have an index */
$result = $mysqli->query("SELECT Name FROM City WHERE population > 50000");
-
- $result->close();
-
- $mysqli->close();
-
} catch (mysqli_sql_exception $e) {
-
- echo $e->__toString();
+ error_log($e->__toString());
}
-?>
]]>
@@ -128,27 +118,45 @@ try {
50000");
+
+ /* this query should report a bad index if the column population doesn't have an index */
+ $result = mysqli_query($link, "SELECT Name FROM City WHERE population > 50000");
+} catch (mysqli_sql_exception $e) {
+ error_log($e->__toString());
}
+]]>
+
+
+
+ Error reporting except bad index errors
+
+ 50000");
+/* activate reporting */
+mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
-/* this query should report a bad index */
-$result = mysqli_query("SELECT Name FROM City WHERE population > 50000");
+try {
+ /* if the connection fails, a mysqli_sql_exception will be thrown */
+ $mysqli = new mysqli("localhost", "my_user", "my_password", "my_db");
-mysqli_free_result($result);
+ /* this query should report an error */
+ $result = $mysqli->query("SELECT Name FROM Nonexistingtable WHERE population > 50000");
-mysqli_close($link);
-?>
+ /* this WILL NOT report any errors even if index is not available */
+ $result = $mysqli->query("SELECT Name FROM City WHERE population > 50000");
+} catch (mysqli_sql_exception $e) {
+ error_log($e->__toString());
+}
]]>
@@ -158,8 +166,6 @@ mysqli_close($link);
&reftitle.seealso;
- mysqli_debug
- mysqli_dump_debug_infomysqli_sql_exceptionset_exception_handlererror_reporting
diff --git a/reference/mysqli/summary.xml b/reference/mysqli/summary.xml
index 7c766a8a8b..f5f3ec613d 100644
--- a/reference/mysqli/summary.xml
+++ b/reference/mysqli/summary.xml
@@ -677,7 +677,10 @@
Properties
+ $mysqli_driver::mysqli_report
+ mysqli_reportN/A
+ Sets mysqli error reporting modeMethods