Possible Duplicate:
Retrieve (or simulate) full query from PDO prepared statement
I can't figure out why my query is returning 0 rows.. it implements some very dynamic search functionality, and a lot of if/loop statements etc. Therefor to debug it, I'd like to see EXACTLY what string is being sent to the server. Is there a way to do this through PHP?
Is there maybe a way to ask the server "what was the last query", or tell PDO "show me what you sent"?
I saw one response using str_replace
to manually enter the values in place of :fieldValue
, but it's likely a syntax problem (or maybe it's going through an incorrect loop, etc), which this method doesn't help with.
Using bindValue(":fieldValue", $value);
if that makes a difference.
EDIT
Turns out it was a simple if ($var="true") { ...
which should have been if ($var=="true") { ...
. PHP I guess is not the same as Java in that sense? Either way, the question still stands (as I run into this often). I had to use a series of echo "You are Here";
to find this error, as it was technically valid but not correct. If I had the final SQL statement, I could have seen "Oh, my code has added the where column = true
, must have gone through the wrong IF...".