如何在Magento中打印所有查询? [英] How do I print all the queries in Magento?
问题描述
是否可以显示Magento中的所有查询字符串?我真的很想看看执行什么查询。
Is it possible to display all the query strings in Magento? I really like to see what queries are executed.
谢谢
推荐答案
我不是100%肯定这将捕获每个查询,但大多数通过查询方法 Zend_Db_Adapter_Abstract
查询
方法
I'm not 100% sure this will catch every query, but most run through the query method Zend_Db_Adapter_Abstract
query
method in
lib/Zend/Db/Adapter/Abstract.php
考虑到这一点,您可以暂时添加一些调试语句(在 app / code公共函数查询($ sql,$ bind = array)
With that in mind, you could temporarily add some debugging statements (to a copy you make in app/code/local/Mage
to be safe)
public function query($sql, $bind = array())
{
// connect to the database if needed
$this->_connect();
// is the $sql a Zend_Db_Select object?
if ($sql instanceof Zend_Db_Select) {
if (empty($bind)) {
$bind = $sql->getBind();
}
$sql = $sql->assemble();
}
echo "{$sql}\n<br />\n";
var_dump($bind);
如果你需要抓住所有这些,你最好在MySQL级别这不一定可能取决于您的主机/ IT情况)
If you need to catch them all, you'd be better off doing this at the MySQL level (which isn't always possible depending on your host/IT situation)
这篇关于如何在Magento中打印所有查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!