有没有办法让堆栈跟踪在出现错误时显示整个生成的 SQL 语句,而不是只显示它的前几个字符?
这是它当前显示的内容
...\Zend\Db\Adapter\Pdo\Abstract.php(220): Zend_Db_Adapter_Abstract->query('UPDATE "diction...', Array)
..我想在发送到数据库之前查看整个更新语句以跟踪它有什么问题。
谢谢您的帮助。SWK
有没有办法让堆栈跟踪在出现错误时显示整个生成的 SQL 语句,而不是只显示它的前几个字符?
这是它当前显示的内容
...\Zend\Db\Adapter\Pdo\Abstract.php(220): Zend_Db_Adapter_Abstract->query('UPDATE "diction...', Array)
..我想在发送到数据库之前查看整个更新语句以跟踪它有什么问题。
谢谢您的帮助。SWK
如果要查看完整的 sql 语句,可以使用 Zend_Debug。例如,如果您的 sql 语句在变量 $select 中,并且您想查看完整的 sql 语句,您可以使用以下代码行:
Zend_Debug::Dump($select);
exit;
或者,如果您的代码是使用 Zend_Db_Table 类创建的,您可以使用:
$select = new Zend_Db_Select(Zend_Registry::get('db'));
$select->from('string');
Zend_Debug::Dump($select->assemble());
exit;
我认为查看 sql 语句的最佳方法是在数据库连接上使用 profiling 函数。这与日志记录功能相结合,Firefox 的 firePHP 插件是我最喜欢的设置。
如果您使用 Zend Framework 的 MVC 配置,则这行代码完成:
// setup the database connection
$db = Zend_Db::factory(Zend_Registry::get('config')->database->adapter,Zend_Registry::get('config')->database->params);
// create a new profiler
profiler = new Zend_Db_Profiler_Firebug('All DB Queries');
// enable profiling (this is only recommended in development mode, disable this in production mode)
$profiler->setEnabled(true);
// add the profiler to the database object
$db->setProfiler($profiler);
// setup the default adapter to use for database communication
Zend_Db_Table_Abstract::setDefaultAdapter($db);
// register the database object to access it in other parts of the project
Zend_Registry::set('db',$db);
/**
*
* This part is optional
*
* You can use this logger to log debug information to the firephp add-on for Firefox
* This is handy for debugging but must be disabled in production mode
*
*/
// create logger
$logger = new Zend_Log();
// create firebug writer
$firebug_writer = new Zend_Log_Writer_Firebug();
// add writer to logger
$logger->addWriter($firebug_writer);
// register the logger object to access it in other parts of the project
Zend_Registry::set('log',$logger);
firebug 插件(firephp 的要求)可以在这个网站上找到: Firebug
FirePHP 插件可以在这个网站上找到: FirePHP
伊沃·特罗珀特
虽然分析器很酷 - 当系统抛出异常时它无助于调试..
查看这篇关于给出更详细的堆栈跟踪 inc 完整 SQL 的帖子
仅出于明显的原因在开发环境中使用
http://www.edmondscommerce.co.uk/blog/zend-framework/zend-framework-more-detailed-stack-trace/