問題描述
是否可以在 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 中打印所有查詢?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!