title: PDO Debugging - View Query AFTER Bind?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/3754530/retrieve-or-simulate-full-query-from-pdo-prepared-statement">Retrieve (or simulate) full query from PDO prepared statement</a>  </p>
  </blockquote>
  
  
  
  <p>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?</p>
  
  <p>Is there maybe a way to ask the server "what was the last query", or tell PDO "show me what you sent"?</p>
  
  <p>I saw one response using <code>str_replace</code> to manually enter the values in place of <code>:fieldValue</code>, but it's likely a syntax problem (or maybe it's going through an incorrect loop, etc), which this method doesn't help with.</p>
  
  <p>Using <code>bindValue(":fieldValue", $value);</code> if that makes a difference.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Turns out it was a simple <code>if ($var="true") { ...</code> which should have been <code>if ($var=="true") { ...</code>. 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 <code>echo "You are Here";</code> 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 <code>where column = true</code>, must have gone through the wrong IF...".</p>