How can I view a prepared PDO SQL Statement

mysql, pdo, php, sql

Solution

You can't get the query which is sent to server because PDO doesn't work this way.

It sends the $query seperately and $id seperately to the server-database which are executed after joining by database.

Problem

Possible Duplicate: PDO Prepared Statements I'm sure the answer to this is very simple, but I don't seem to be able to find it. I'm using PDO (PHP Data Objects) to run a query against a MySQL database, and would find it useful to display the prepared query before it is executed against the DB. Is there any way of doing this? For example: ``` $query = 'SELECT Id, Name, Comment FROM Users WHERE Id = :id'; $pdoStatement = $db->prepare($query); $pdoStatement->bindValue(':id', $id); // How can I view the actual statement that will be executed, showing the real // value that will be used in place of ':id' $pdoStatement->execute(); ```

Original source

Related problems