I'm making the change from mysql_*
calls to using PDO calls and am unable to figure out how to debug my actual SQL when developing new code.
Under mysql_*
calls I could write some SQL in a PHP function and could echo
the actual SQL to see what the processor was working with.
I haven't been able to find such a beastie in the PDO library. debugDumpParams
looks like it should, but it doesn't spit back the bound statement.
Examples of problems I have encountered:
In my very first attempt I was binding a string and was including the quotes in the SQL statement, despite binding with a data_type of string - it was only by fluke I tried removing the quotes from the statement; debugging would have let me see there was a repeated quote in there.
I copied some code from one project to another and accidentally forgot to correct the database name. Naturally the SQL failed because the tables didn't exist in the other DB. But the program just returned the correct false result. Nowhere in the PHP logs or the MySQL logs or anywhere did I get a hint that the table didn't exist where I was looking for it.
So, how are other people doing debugging for PDO SQL calls? What am I missing? :)