Jawaban:
Jika Anda ingin memastikan semua SQL benar-benar masuk, saya sarankan untuk menggunakan perangkat lunak pihak ketiga:
Sebagai alternatif, pendekatan Magento / Varien asli bisa menjadi yang berikut:
lib/Varien/Db/Adapter/Pdo/Mysql.php
true
(baris 103)var/debug/pdo_mysql.log
Baris berikut harus diubah: (komentar cukup jelas)
/**
* Write SQL debug data to file
*
* @var bool
*/
protected $_debug = true;
/**
* Minimum query duration time to be logged
*
* @var float
*/
protected $_logQueryTime = 0.05;
/**
* Log all queries (ignored minimum query duration time)
*
* @var bool
*/
protected $_logAllQueries = true;
/**
* Add to log call stack data (backtrace)
*
* @var bool
*/
protected $_logCallStack = true;
Log yang dihasilkan seperti berikut ini:
## 2014-06-26 12:18:47
## 10258 ## QUERY
SQL: SELECT `adminnotification_inbox`.* FROM `adminnotification_inbox` WHERE (title = 'Customize your order and invoice numbers to protect your sales using Order Number Customizer by XTENTO.') AND (url = 'http://www.xtento.com/magento-extensions/order-number-customizer.html?utm_source=feed&utm_medium=feed&utm_campaign=order_number_customizer')
AFF: 1
TIME: 0.0008
Jika Anda telah mengaktifkan, $_logCallStack
Anda juga akan memiliki bagian TRACE
TRACE: #1 Varien_Db_Adapter_Pdo_Mysql#00000000644036ff00007f14137095e6#->_debugStat(2, 'SELECT `adminnot...', array(), &Varien_Db_Statement_Pdo_Mysql#000000006440371700007f14137095e6#) called at [lib/Varien/Db/Adapter/Pdo/Mysql.php:424]
#2 Varien_Db_Adapter_Pdo_Mysql#00000000644036ff00007f14137095e6#->query(&Varien_Db_Select#000000006440371800007f14137095e6#, array()) called at [lib/Zend/Db/Adapter/Abstract.php:753]
#3 Varien_Db_Adapter_Pdo_Mysql[Zend_Db_Adapter_Abstract]#00000000644036ff00007f14137095e6#->fetchRow(&Varien_Db_Select#000000006440371800007f14137095e6#) called at [app/code/core/Mage/AdminNotification/Model/Resource/Inbox.php:116]
#4 Mage_AdminNotification_Model_Resource_Inbox#00000000644034c500007f14137095e6#->parse(&Mage_AdminNotification_Model_Inbox#00000000644034e900007f14137095e6#, array(array('severity' => 4, 'date_added' => '2013-10-23 13:00...', 'title' => 'Customizing your...', 'description' => 'Easily add new c...', 'url' => 'http://www.xtent...'), array('severity' => 4, 'date_added' => '2014-04-09 17:00...', 'title' => 'Customize your o...', 'description' => 'Customize your M...', 'url' => 'http://www.xtent...'), array('severity' => 4, 'date_added' => '2014-05-06 17:00...', 'title' => 'Process orders i...', 'description' => 'Process all your...', 'url' => 'http://www.xtent...'))) called at [app/code/core/Mage/AdminNotification/Model/Inbox.php:118]
#5 Mage_AdminNotification_Model_Inbox#00000000644034e900007f14137095e6#->parse(array(array('severity' => 4, 'date_added' => '2013-10-23 13:00...', 'title' => 'Customizing your...', 'description' => 'Easily add new c...', 'url' => 'http://www.xtent...'), array('severity' => 4, 'date_added' => '2014-04-09 17:00...', 'title' => 'Customize your o...', 'description' => 'Customize your M...', 'url' => 'http://www.xtent...'), array('severity' => 4, 'date_added' => '2014-05-06 17:00...', 'title' => 'Process orders i...', 'description' => 'Process all your...', 'url' => 'http://www.xtent...'))) called at [app/code/local/Xtento/XtCore/Model/Feed.php:57]
#6 Xtento_XtCore_Model_Feed#000000006440348500007f14137095e6#->checkUpdate(&Varien_Event_Observer#00000000644034d900007f14137095e6#) called at [app/code/core/Mage/Core/Model/App.php:1338]
#7 Mage_Core_Model_App#00000000644036ef00007f14137095e6#->_callObserverMethod(&Xtento_XtCore_Model_Feed#000000006440348500007f14137095e6#, 'checkUpdate', &Varien_Event_Observer#00000000644034d900007f14137095e6#) called at [app/code/core/Mage/Core/Model/App.php:1317]
#8 Mage_Core_Model_App#00000000644036ef00007f14137095e6#->dispatchEvent('controller_actio...', array('controller_actio...' => &Fishpig_Wordpress_Adminhtml_WordpressController#000000006440364a00007f14137095e6#)) called at [app/Mage.php:451]
#9 Mage::dispatchEvent('controller_actio...', array('controller_actio...' => &Fishpig_Wordpress_Adminhtml_WordpressController#000000006440364a00007f14137095e6#)) called at [app/code/core/Mage/Core/Controller/Varien/Action.php:528]
#10 Fishpig_Wordpress_Adminhtml_WordpressController[Mage_Core_Controller_Varien_Action]#000000006440364a00007f14137095e6#->preDispatch() called at [app/code/core/Mage/Adminhtml/Controller/Action.php:160]
#11 Fishpig_Wordpress_Adminhtml_WordpressController[Mage_Adminhtml_Controller_Action]#000000006440364a00007f14137095e6#->preDispatch() called at [app/code/core/Mage/Core/Controller/Varien/Action.php:408]
#12 Fishpig_Wordpress_Adminhtml_WordpressController[Mage_Core_Controller_Varien_Action]#000000006440364a00007f14137095e6#->dispatch('checkVersion') called at [app/code/core/Mage/Core/Controller/Varien/Router/Standard.php:250]
#13 Mage_Core_Controller_Varien_Router_Admin[Mage_Core_Controller_Varien_Router_Standard]#00000000644036ae00007f14137095e6#->match(&Mage_Core_Controller_Request_Http#000000006440365c00007f14137095e6#) called at [app/code/core/Mage/Core/Controller/Varien/Front.php:176]
#14 Mage_Core_Controller_Varien_Front#000000006440365700007f14137095e6#->dispatch() called at [app/code/core/Mage/Core/Model/App.php:354]
#15 Mage_Core_Model_App#00000000644036ef00007f14137095e6#->run(array('scope_code' => '', 'scope_type' => 'store', 'options' => array())) called at [app/Mage.php:687]
#16 Mage::run('', 'store') called at [index.php:87]
Aktifkan Zend SQL Profiler dengan simpul berikut di Anda app/etc/local.xml
<resources>
<default_setup>
<connection>
<profiler>1</profiler>
Kemudian Anda dapat mengakses profiler di suatu tempat dalam kode Anda dan mengambil banyak informasi tentang semua permintaan yang dieksekusi:
$profiler = Mage::getSingleton('core/resource')->getConnection('core_write')->getProfiler();
Untuk sekadar menampilkan semua pertanyaan:
print_r($profiler->getQueryProfiles());
Anda dapat menambahkan dua baris ini di akhir index.php
untuk melihat semua pertanyaan di bagian bawah setiap halaman. Ketahuilah bahwa ini akan memecah permintaan AJAX yang mengembalikan respons JSON, jadi Anda dapat mempertimbangkan untuk mencatat kueri alih-alih mencetaknya, dengan kode ini (sekali lagi, tambahkan di akhir index.php
):
$profiler = Mage::getSingleton('core/resource')->getConnection('core_write')->getProfiler();
Mage::log(print_r($profiler->getQueryProfiles(), true), null, 'queries.log', true);
Maka Anda akan menemukan semua kueri di var/log/queries.log
Jangan lupa untuk menghapus baris lagi setelah Anda selesai men-debug!
Saya tidak 100% yakin ini akan menangkap setiap kueri, tetapi sebagian besar dijalankan melalui metode kueri Zend_Db_Adapter_Abstrak metode kueri di
lib / Zend / Db / Adaptor / Abstract.php
Dengan mengingat hal itu, Anda dapat secara sementara menambahkan beberapa pernyataan debug (ke salinan yang Anda buat
app / code / local / Mage
agar selamat)
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);
Jika Anda memiliki akses ke server mysql dan Anda tidak memiliki proyek lain yang menjalankan kueri, Anda dapat mencoba menambahkan log umum dari mysql. Lihat di sini tentang cara melakukannya /programming/6479107/how-to-enable-mysql-query-log karena itu menulis semua pertanyaan, file log bisa menjadi besar dengan sangat cepat, jadi pastikan untuk menghidupkan off setelah Anda selesai dengan itu.