Click here to Skip to main content
15,890,690 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
its not woking
PHP
public function getLastQuery() {
  $dbo = $this->getDatasource();
  $logs = $dbo->getLog();
  $lastLog = end($logs['log']);
  return $lastLog['query'];
}
Posted
Updated 8-Jan-18 22:34pm

1 solution

That solution work in Cake 2.0 only if you have debug mode 2 or more. If you are in Cake 1.x you should do this

PHP
function getLastQuery()
{
    $dbo = $this->getDatasource();
    $logs = $dbo->_queriesLog;

    return end($logs);
}


that code should go on app/app_model.php so is accesible for all your models.
 
Share this answer
 
Comments
Sradhanjali Behera 23-Jan-15 7:09am    
for cake 2.6 what is the function? @Member 11397060

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900