What are the advanced Mysqli debugging features?

The mysqli overview page has a list of benefits designed to lure me into the mysqli realm. I don’t even understand the meaning of many of them, but I’m really interested in: advanced debugging features.

According to my experience, prepared statements (which are considered the main and mainly used mysqli function) significantly complicate the debugging of dynamic SQL - you simply cannot have a regular query from a prepared query for copying to the console.
So, I really want to know what these opportunities are and how to use them.
Is it SQL debugging or something else?
How to use it?
What are the practical use cases?

+6
source share
2 answers

I think this means:

They do not exist with mysql api, only mysqli.

You can, among other things, create trace files :

mysqli_debug("d:t:o,/tmp/client.trace"); 

I understand that tracing is about debugging the internal behavior of MySQL. If you suspect a problem with MySQL, you can use this. For debugging SQL, I would use lighter dimensions, even if the trace also shows them.

You can see an example of such trace output on this page .

+5
source

About the prepared statement, theoretical, you will find out that your kwery is poorly formatted before sending the parameters. Therefore, you do not have to wonder if this is your request or the user data that is being listened to, you know it immediately.

About general queries, since mysqli synchronizes with MySQL5, while mysql_ does not support the old API until MYSQL 4, you will have the best error message, or at least the most descriptive one.

Alternatively, you can use the try \ catch syntax to detect mysql errors, and it is easier to handle exceptions instead of or die.... or if(mysql_error()) .

from the documentation you have:

 <?php define("MYSQL_CONN_ERROR", "Unable to connect to database."); // Ensure reporting is setup correctly mysqli_report(MYSQLI_REPORT_STRICT); // Connect function for database access function connect($usr,$pw,$db,$host) { try { $mysqli = new mysqli($host,$usr,$pw,$db); $connected = true; } catch (mysqli_sql_exception $e) { throw $e; } } try { connect('username','password','database','host'); echo 'Connected to database'; } catch (Exception $e) { echo $e->errorMessage(); } 

mysqli_report(MYSQLI_REPORT_STRICT) key function mysqli_report(MYSQLI_REPORT_STRICT) , according to the documentation:

MYSQLI_REPORT_STRICT

 Throw a mysqli_sql_exception for errors instead of warnings. 

there is also a / t mysqli_debug like eis.

+1
source

All Articles