Is there a way to print the actual query that mysqli-> execute () does?

I have a complex query that runs as follows:

if ($stmt = $dbi->prepare($pt_query)) { $stmt->bind_param('ssssssssi', $snome,$scognome,$ssocieta,$svia,$slocalita,$sprovincia,$scap,$stelefono,$sfax,$uid); $stmt->execute(); echo $dbi->error; $stmt->close(); } else { printf("Error -> %s\n", $dbi->error); } 

This thing fails without any error, it just does not update the database. Since there is a ton of data that is processed before this thing, I would like to know if there is a way to show the actual query that mysqli executes in order to understand where the problem is.

Thanks.

+7
php mysqli
source share
4 answers

If your statement does not work, you should check $stmt->error (unlike $dbi->error ). As for getting the actual text of the request: this is not possible. When using prepared statements, the library uses a special protocol that does not generate the actual query string for each call ->execute() .

+8
source share

You can enable logging directly in the MySQL database, i.e. add the line log = logfile to my.ini.

Refer to the MySQL documentation for more information if necessary.

+5
source share

Based on mysql php site there is no real way to do this. But you can try this function as it gives you errors in your request.

0
source share

Here is a tool I found that can help MySQLi Prepare validation checks

0
source share

All Articles