How to Make Magento Show The Entire SQL Error
Every once in awhile I am programming something in Magento and I get a MySQL erro开发者_如何学运维r. 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?
You can set on the debug mode in mysql adapter (Varien_Db_Adapter_Pdo_Mysql)
/**
* Write SQL debug data to file
*
* @var bool
*/
protected $_debug = true;
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.
Edit Zend_Db_Statement_Pdo#_execute
method to include $this->_stmt->queryString
in the thrown exception message.
Here's a module that pretty prints the SQL as well:
https://github.com/kalenjordan/pretty-sql-exception
精彩评论