How do I print all the queries in 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 中打印所有查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 Magento 中打印所有查询?
基础教程推荐
- 如何在 Laravel 中使用 React Router? 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- 如何替换eregi() 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
