Is there a way that one can cause CakePHP to dump its SQL log on demand? I\'d like to execute code up until a point in my controller and see what SQL has been run.
for cakephp 2.0 Write this function in AppModel.php
function getLastQuery() { $dbo = $this->getDatasource(); $logs = $dbo->getLog(); $lastLog = end($logs['log']); return $lastLog['query']; }
To use this in Controller Write : echo $this->YourModelName->getLastQuery();