-2

I have a query that I'm executing with PDO that has bind variables. If I echo out the statement's queryString value and substitute the bind variables myself, and execute the query, I get returned rows. I was hoping someone could give me some pointers on debugging this issue.


I'm awarding VMai's answer, because he gave me some good debugging tips. I discovered that in my case the problem was due to using bindParam() in a foreach loop. Creating a code snippet where the only difference was the foreach loop is what got me researching in that direction. I didn't need the functionality that bindParam affords, so switching to bindValue fixed the bug.

Community
  • 1
  • 1
Sonny
  • 8,204
  • 7
  • 63
  • 134
  • 6
    showing some code would be a good start. there's literally an infinite number of reasons it's not working. showing some code will help nail that infinity down to something a wee bit more manageable. – Marc B Apr 09 '14 at 17:53
  • There are a few layers of abstraction, so showing a relevant code snippet is problematic. I was hoping for more generalized debugging tips. – Sonny Apr 09 '14 at 17:57

1 Answers1

0

You can use PDOStatement::debugDumpParams to get information about the prepared statement, see http://www.php.net/manual/en/pdostatement.debugdumpparams.php

Otherwise you can enable the general query log of your MySQL server in my.cnf. http://dev.mysql.com/doc/refman/5.5/en/query-log.html

VMai
  • 10,156
  • 9
  • 25
  • 34