How to print last executed query in cakephp?

In the Cakephp, the printing of last executed query is not so much good as CodeIgniter.

Here is the code, by using this we can print the last executed query in cakephp

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

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

 

Now, you can see the last executed query.

 

OUTPUT:

Array
(
     [query] => SELECT * FROM .......
     [params] => Array    
                    (
                    )
      [affected] => 0
      [numRows] => 0
      [took] => 3
)

 

Leave a Reply

Your email address will not be published. Required fields are marked *