How to Print Last Executed Query in CakePhp?

How to Print Last Executed Query in CakePhp?

 

Here, ModelName is the Query from Model Name

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


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

 

# The Output will come like this….

 

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 *