加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – 为什么PDO debugDumpParams截断查询

发布时间:2020-12-13 16:56:01 所属栏目:PHP教程 来源:网络整理
导读:我发现了同样的问题 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 directl
我发现了同样的问题 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,which dump directly the data on the normal output.
        Tip:
        As with anythi
Params:  0

它为什么会发生,如何解决?
?提前致谢!

解决方法

我认为debugDumpParams整体上是一种错误.它只是在标准输出中直接吐出数据!

因此我无论如何都不会使用它,并且为了记录目的要么启用mysql的通用日志,要么创建一个带有日志记录功能的PDO包装器(此解决方案更具可移植性).

(编辑:李大同)

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

    推荐文章
      热点阅读