Print last executed query in Cakephp 2.0


Print last executed query in Cakephp 2.0 : For each developer it becomes very important to print the last executed query in all frameworks. It helps much in development for debugging the queries. Here we are going to explain the method how you can print the last executed query in cakephp 2.0.


Print last executed query in Cakephp 2.0

You can print last executed query in cakephp as below-

Example:

  $dbo = $this->getDatasource();
  // or $dbo = $this->Model->getDatasource();
  $log = $dbo->getLog();
  $last_log = end($log['log']);
  return $last_log['query'];

The above example will print the last executed query in cakephp2.0


Advertisements

Add Comment

📖 Read More