Actually,
I have written this code in AppController.php in CakePHP 2.2.2
class AppModel extends Model
{
function getLastQuery()
{
$dbo = $this->getDatasource();
$logs = $dbo->getLog();
$lastLog = end($logs['log']);
return $lastLog['query'];
}
}
I tried following code to print output query
echo $this->AssetModel->getLastQuery();
$this->render('sql');
Is any body know to the point solution for that....?
Hi you can use the below line to put into your layout file
this will print all running query running in current action.
You can also use cakephp debugkit plugin.