如何在 Magento 中打印所有查询?

How do I print all the queries in Magento?(如何在 Magento 中打印所有查询?)
本文介绍了如何在 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 query 方法在

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/local/Mage 中制作的副本中)

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}
<br />
";
    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 中打印所有查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

In PHP how can you clear a WSDL cache?(在 PHP 中如何清除 WSDL 缓存?)
failed to open stream: HTTP wrapper does not support writeable connections(无法打开流:HTTP 包装器不支持可写连接)
Stop caching for PHP 5.5.3 in MAMP(在 MAMP 中停止缓存 PHP 5.5.3)
Caching HTTP responses when they are dynamically created by PHP(缓存由 PHP 动态创建的 HTTP 响应)
Memcached vs APC which one should I choose?(Memcached 与 APC 我应该选择哪一个?)
What is causing quot;Unable to allocate memory for poolquot; in PHP?(是什么导致“无法为池分配内存?在 PHP 中?)