Debug sql in Magento

magento

To enable the debug sql in Magento. You let’s open to file:

lib/Varien/Db/Adapter/Pdo/Mysql.php
In content file Mysql.php. You let’s set value for two variable:
protected $_debug = true;
protected $_logAllQueries = true;

Enable $_debug to enable function debug sql.
Enable $_logAllQueries to log all query string.
and other variables as:
protected $_logQueryTime: time run minimum of query to be logged.
protected $_logCallStack: In addition to the queries, it logs a backtrace of the methods that called the query, if you’ve turned enable the option to $_logQueryTime, this option will produce even more data to sift through.
protected $_debugFile variable is link create file log. Default Magento is ‘var/debug/pdo_mysql.log’

Hence, any manipulation access to sql will log to content file pdo_mysql.log.

 

debug sql

 

Content file pdo_mysql.log