如何让 Magento 显示整个 SQL 错误
每隔一段时间,我在 Magento 中编程时就会收到 MySQL 错误。当屏幕上显示异常时,它仅显示尝试执行的查询的前几个字符。
有没有办法让 Magento 在堆栈跟踪中显示整个查询?
Every once in awhile I am programming something in Magento and I get a MySQL error. When the exception displays on the screen it only displays the first few characters of the query that it was trying to execute.
Is there a way to get Magento to display the entire query in the stack trace?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以在mysql适配器(Varien_Db_Adapter_Pdo_Mysql)中设置调试模式
转到文件(var/debug/sql.txt),找到异常获取查询并在mysql工具中执行它。
问题是 PDO 仅返回部分错误,只有当您在某些工具中执行查询时才能看到完整的错误消息。
You can set on the debug mode in mysql adapter (Varien_Db_Adapter_Pdo_Mysql)
Go to file (var/debug/sql.txt), find the exception get query and execute it in mysql tool.
The problem is the PDO returns only part of the error, the full error message you can see only when you execute your query in some tool.
编辑
Zend_Db_Statement_Pdo#_execute
方法以在抛出的异常消息中包含$this->_stmt->queryString
。Edit
Zend_Db_Statement_Pdo#_execute
method to include$this->_stmt->queryString
in the thrown exception message.这是一个可以漂亮打印 SQL 的模块:
https://github.com/kalenjordan/pretty- sql异常
Here's a module that pretty prints the SQL as well:
https://github.com/kalenjordan/pretty-sql-exception