使用PHP PDO显示bindParam的值 [英] Display value of bindParam using PHP PDO

查看:46
本文介绍了使用PHP PDO显示bindParam的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种简单的方法可以回显绑定参数中存储的值.

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;

推荐答案

如果您只想看看"发生了什么,则可以使用 PDOStatement-> debugDumpParams():

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

将准备好的语句所包含的信息直接转储到输出中.它将提供使用中的SQL查询,使用的参数数量(参数),参数列表及其名称,类型(参数类型)为整数,键名称或位置,值以及查询中的位置(如果PDO驱动程序支持,则为-1).
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).

这篇关于使用PHP PDO显示bindParam的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆