Home >Backend Development >PHP Tutorial >Why Don't MySQLi Queries Throw Exceptions Even with `mysqli_report(MYSQLI_REPORT_STRICT)`?
Despite setting mysqli_report(MYSQLI_REPORT_STRICT), query errors in MySQLi don't throw exceptions. mysqli_sql_exception is only thrown for connection errors. Is it normal to manually check for mysqli_query()'s return value to detect query failures?
Yes, manual checking is often necessary because:
Former code:
$result = mysqli_query($DBlink, $SQL); if($result === false) { throw new MySQLiQueryException($SQL, mysqli_error($DBlink), mysqli_errno($DBlink)); }
Instead, only use try-catch sparingly for errors that require immediate attention.
The above is the detailed content of Why Don't MySQLi Queries Throw Exceptions Even with `mysqli_report(MYSQLI_REPORT_STRICT)`?. For more information, please follow other related articles on the PHP Chinese website!