How to get Last Executed Query in Cakephp

QuestionsCategory: CakephpHow to get Last Executed Query in Cakephp
Samar asked 1 year ago

How to Get Last Executed Query in Cakephp? Here, I have to print the Last Executed Query to check what query is generating.

1 Answers
Best Answer
devchandan Staff answered 1 year ago

For print Last Executed Query in Cakephp, you can use this…
 

$dbo = $this->ModelName->getDatasource(); 
$logs = $dbo->getLog();
$log = end($logs['log']);

echo
"<pre>"; print_r($log); echo "</pre>";
exit();

 
Here, ModelName is the Query from Model Name
For more Click Here

http://www.stackofcodes.in/2018/09/17/how-to-print-last-executed-query-in-cakephp/