php – 为什么PDO debugDumpParams截断查询
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了php – 为什么PDO debugDumpParams截断查询,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1727字,纯文字阅读大概需要3分钟。
内容图文
我发现了同样的问题here,但没有答案,我在这里提供了更简单的例子,并再试一次……
码:
<?php
$dbh = new PDO('mysql:dbname=test;host=127.0.0.1', 'root');
$sth = $dbh->prepare("
SELECT '
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, and the position in the query (if this is supported by the PDO driver, otherwise, it will be -1).
This is a debug function, which dump directly the data on the normal output.
Tip:
As with anything that outputs its result directly to the browser, the output-control functions can be used to capture the output of this function, and save it in a string (for example).
This will only dumps the parameters in the statement at the moment of the dump. Extra parameters are not stored in the statement, and not displayed.
'
");
$sth->execute();
$sth->debugDumpParams();
结果:
SQL: [835]
SELECT '
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, and the position in the query (if this is supported by the PDO driver, otherwise, it will be -1).
This is a debug function, which dump directly the data on the normal output.
Tip:
As with anythi
Params: 0
它为什么会发生,如何解决?
提前致谢!
解决方法:
我认为debugDumpParams整体上是一种错误.它只是在标准输出中直接吐出数据!
因此我无论如何都不会使用它,并且为了记录目的要么启用mysql的通用日志,要么创建一个带有日志记录功能的PDO包装器(此解决方案更具可移植性).
内容总结
以上是互联网集市为您收集整理的php – 为什么PDO debugDumpParams截断查询全部内容,希望文章能够帮你解决php – 为什么PDO debugDumpParams截断查询所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。