Output raw SQL query from Magento collection

爷,独闯天下 提交于 2019-12-10 13:46:35

问题


I have the following collection and want to view the raw SQL within my IDE Xdebug tool -

$collection = Mage::getResourceModel('rp/organisation_collection')
                ->searchByPostcodeLastname($postcode, Slastname)
                ->addFieldToSelect(array('organisation_id'))
                ->setPageSize(1);

$qry = $organisation->load()->getSelect();

This while does show the Varien object doesn't seem to give me the raw SQL for me to check - can someone confirm what I am doing wrong?


回答1:


Try

$collection->getSelect()->__toString()

See How do you display a Magento sql query as a string?




回答2:


Try out $Collection->printLogQuery(true); this will print collection query.

Mage::log($collection->getSelect(),null,'test.log',true);


来源:https://stackoverflow.com/questions/23834183/output-raw-sql-query-from-magento-collection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!