Display value of bindParam using PHP PDO

pdo, php

Solution

If you only want to "see" what's going on then there's PDOStatement->debugDumpParams():

Dumps the informations contained by a prepared statement directly on the output. It will provide the SQL query in use, the number of parameters used (Params), the list of parameters, with their name, type (paramtype) as an integer, their key name or position, the value, and the position in the query (if this is supported by the PDO driver, otherwise, it will be -1).

Problem

Is there an easy way to echo the value stored in a bound parameter. ``` $sql ="call storedproc(:firstname, :lastname)"; $stmt = $this->DBH->prepare($sql); $stmt->bindParam(':firstname', $fname); $stmt->bindParam(':lastname', $lname); //I want to do this echo $stmt->firstname; $stmt->execute; ```

Original source