How to print last executed query in CakePHP2?

Follow the following steps to print last executed query in CakePHP2: To print last executed query: Add below code in app_model.php file which is located at root/cake/libs/model. public function getLastQuery() { Configure::write('debug', '2'); $dbo = $this->getDatasource(); $logs = $dbo->getLog(); $lastLog = end($logs['log']); return $lastLog['query']; } Add below line in your model where you want print […]

Read More