phpmysqlodbcprepared-statementdatabase-tools

How to monitor SQL (which uses prepared stataments)?


When first developing an PHP app (MySQl, but using ODBC interfaces to allow for future expansion), I was simply assigning my SQL to a variable and calling odbc_exec().

That made debugging simple, as I just had to examine my variable $sql.

Of course, I soon realized that I have to use prepared statements to sanitize user input.

My question is how to discover the exact SQL which is being executed in the databse, in order to debug my prepared statements.

I reazlise that I can't do it from PHP, but are their any external monitor tools which can interecpt the SQL? Or even a MySql command to echo, if I leave a console window open?


Solution

  • Use the MySQL query log.