The php Function Mysqli_Report
The php function mysqli_report is a powerful tool to use for optimizing your queries and code during development and testing. It reports errors generated by mysqli functions in several different ways depending on the flags passed to it. It can be used to identify a variety of problems including query execution times exceeding the max allowed value and even queries that do not use an index at all. It also reports errors caused by improper escaping (mysqli::real_escape_string()) and bind parameters not set to the correct values (mysqli::bind_param()).
It can be very useful to have an error reporting mode that works just like mysqli_connect(). This eliminates cryptic error messages such as mysqli::fetch_assoc() expects parameter 'x' when it should be 'y' or expects call to member function 'bind_param()' when it should be'mysqli_fetch_assoc()'.
In object-oriented programming you have to be very careful when using mysqli prepared statements, especially when they are parameterized. Incorrectly escaped strings can cause many different problems such as empty JSON_encode() output, errors with the mysqli::store_result() function and even a crash with the mysqli::fetch_assoc() function.
In PDO, you can choose which way you want to handle these errors by changing the PDO::ATTR_ERRMODE attribute with the mysqli_pdo() constructor method. Alternatively, you can change the report mode for mysqli_report() to STRICT. Then every function that returns an error will throw a mysqli_sql_exception which is a MySQLi specific exception class inherited from the more general RuntimeException. This is very useful when you are developing and testing your application as it will help you catch most of the bugs in your code and fix them before they can even make it to production.