加入收藏 | 设为首页 | 会员中心 | 我要投稿 莱芜站长网 (https://www.0634zz.com/)- 云连接、建站、智能边缘云、设备管理、大数据!
当前位置: 首页 > 编程开发 > PHP > 正文

php – 从PDO准备语句中检索(或模拟)完整查询

发布时间:2020-07-22 09:35:01 所属栏目:PHP 来源:互联网
导读:我从两年前就绊倒了 this question. Is there a way to get the raw SQL string executed when calling PDOStatement::execute() on a prepared statement? For debugging purposes this would be extremely useful. 获胜的答案说明

我从两年前就绊倒了 this question.

Is there a way to get the raw SQL string executed when calling PDOStatement::execute() on a prepared statement? For debugging purposes this would be extremely useful.

获胜的答案说明

[…] You can also get what you want if you
set the PDO attribute
PDO::ATTR_EMULATE_PREPARES. In this
mode,PDO interpolate parameters into
the SQL query and sends the whole
query when you execute().

但是没有提到如何获取生成的查询字符串.我知道这是一个不错的主意性能明智,但这并不打扰我在调试模式.有人知道该怎么做吗

PS如果有一些方法我可以重新开始/提请注意原来的两年老话题,而不是开一个新话题,请让我知道.

我相信这是在原来的问题中提及的.然而
实际上应该是一种检索此数据的方法.

PDOStatement对象:: debugDumpParams

然而,它目前还没有被记录在案.有一个bug报告和补丁提交给它在这里http://bugs.php.net/bug.php?id=52384,以防任何人有兴趣投票.直到它被修复,好像您可以使用查询日志记录或使用PDO :: ATTR_STATEMENT_CLASS属性设置自定义语句类.

(编辑:莱芜站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读