I am using function getLastQuery() with debug value=2 in config file then it will provide us the last executed query but I have to work on a live website where we can not able to set debug=2 because if When we do this all warnings and errors start appearing in the frontend. So I want to use getLastQuery() function with debug=0 but it doesn't work.
Please suggest some alternative to this to print the last executed query without setting debug=2.
I tried this
$query = $this->ShopifyProduct->getLastQuery();
In CakePHP 2, to log the queries without setting the debug level to 2, you can add the following code to your controller or model:
You can then use CakePHP's CakeLog class to write the query log to a file or any other destination. For example: