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

时间:2022-10-21
本文介绍了如何在 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 中打印所有查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

上一条:Magento 安装抱怨 InnoDB 可用时丢失 下一条:Magento 的当前用户?

相关文章

最新文章