作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我发现了同样的问题 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 截断查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29410151/
当使用 PDO::debugDumpParams 时,对于“选定”查询输出显示的字符数是否有最大限制?在大约 500 个字符后,查询将在查询中间结束,而在输出准备 $query 变量时,将显示完整的查
我正在尝试为自己创建一封关于 pdo mysql 错误的有用电子邮件,我正在查看“debugDumpParams”,但遗憾的是由于某种原因它只是将信息转储到屏幕上,您需要使用输出控制函数来设置它是一个
我发现了同样的问题 here但是没有人回答,我在这里提供了更简单的例子,然后再问... 代码: prepare(" SELECT ' Dumps the information
我是一名优秀的程序员,十分优秀!