stmt = $this->dbh->p-6ren">
gpt4 book ai didi

php 在执行后回显查询的实际语句

转载 作者:行者123 更新时间:2023-11-30 01:22:12 24 4
gpt4 key购买 nike

自从我转向 PDO 以来,这让我很沮丧

我有这样的东西:

$sql = "select * FROM $table where id=:id";
$this->stmt = $this->dbh->prepare($query);
$this->stmt->bindValue($param, $value, $type);
bindValue(:id => $this->user_id);
$this->stmt->execute();

现在选择运行,不会破坏任何东西,但我没有得到预期的结果,如果我 echo $this->stmt 我得到这样的东西:

PDOStatement Object ( [queryString] => UPDATE `users` 
SET user_active= :user_active, user_activation_hash= :user_activation_hash
WHERE user_id = :user_id AND user_activation_hash = :verification_code )

现在看起来不错,所以问题很可能出在传递的值上,所以我可能不会传递数字,而是弄乱了引号并将 $id 作为字符串传递,并且它没有评估变量,但我无法找到出路查看实际的报表值是什么。一定有一种更简单的方法,使用标准 mysql 非常简单,只需将查询分配给一个变量并回显它,或者使用或死亡 mysql_error?

fwiw我尝试了debugDumpParams,它只返回这个:

UPDATE `users` SET user_active= :user_active, user_activation_hash= :user_activation_hash WHERE user_id = :user_id AND user_activation_hash = :verification_code Params: 4 Key: Name: [12] :user_active paramno=-1 name=[12] ":user_active" is_param=1 param_type=2 Key: Name: [21] :user_activation_hash paramno=-1 name=[21] ":user_activation_hash" is_param=1 param_type=2 Key: Name: [8] :user_id paramno=-1 name=[8] ":user_id" is_param=1 param_type=2 Key: Name: [18] :verification_code paramno=-1 name=[18] ":verification_code" is_param=1 param_type=2

猜测没有调试转储值或类似的值,这是我想要调试的值

最佳答案

使用$stmt->debugDumpParams();

关于php 在执行后回显查询的实际语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18414803/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com