magento/magento2 — pull request #176 by colinmollenhour (2012-12-28 19:28:10+00:00)
Title: Add print/log query flags to collection

It is very frequent that I am editing code that deals with a collection and I want to print or log the query but finding the point at which the query is actually loaded is often not very easy and is often somewhere in core code which should not be edited. This patch allows one to set a flag on the collection so that when it is loaded it will be printed/logged.

E.g., from an event observer:

$collection = $observer->getCollection();
$collection->addFieldToFilter('foo', 'bar');
$collection->setFlag('print_query', 1);