5

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?

Zabs
  • 13,852
  • 45
  • 173
  • 297

2 Answers2

10

Try

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

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

Community
  • 1
  • 1
MagePal Extensions
  • 17,646
  • 2
  • 47
  • 62
-1

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

Mage::log($collection->getSelect(),null,'test.log',true);
Undo
  • 25,519
  • 37
  • 106
  • 129