0

How can I see the SQL statements which go to the database when using PDO?

openfrog
  • 40,201
  • 65
  • 225
  • 373
  • You are using prepared statements and wonder if `WHERE x=:x AND y=:y` is somewhere "translated" to `WHERE x='abc' AND y='xyz'` and if you can inspect it? – VolkerK Dec 22 '09 at 11:05
  • exactly. that's one possible situation. – openfrog Dec 22 '09 at 12:10
  • I just realized that my question is basically a dupe: http://stackoverflow.com/questions/2411182/how-to-debug-pdo-database-queries Some good suggestions were left there, too. – Nathan Long Mar 09 '10 at 18:25

2 Answers2

1

I don't know how to do this with bare PDO, but if you wrap PDO in a Zend_Db_Adapter, then you can use Zend_Db_Profiler.

Then you'll be able to see the parameterized queries, together with the parameter values. Also, its profiling, i.e. measuring the query execution times.

Ivan Krechetov
  • 18,802
  • 8
  • 49
  • 60
1

If you are using MySQL, enable the query log?

keimol
  • 26
  • 1