Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display value of bindParam using PHP PDO

Tags:

php

pdo

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;
like image 596
patnz Avatar asked Sep 07 '10 06:09

patnz


1 Answers

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).
like image 165
VolkerK Avatar answered Sep 30 '22 16:09

VolkerK