I want to get the last query CakePHP ran. I can't turn debug on in core.php and I can't run the code locally. I need a way to get the last sql query and log it to the error log without effecting the live site. This query is failing but is being run.
something like this would be great:
$this->log($this->ModelName->lastQuery);
Thanks in advance.
Having a quick skim of the book, cakephp api getLog you could turn on
logTransaction
. Although having not used it, I'm not sure how it will perform.Otherwise you could experiment with FirePHP and here is the a guide for it,
You might try DebugKit, although off the top of my head I think you do still need debug 2 to get it to work.
Hopefully something might give you a lead. :)
You can use this inline.
This is a very late answer, i know, but for whoever needs this in the future, you can always restrict setting debug to your IP, For example:
Tested in CakePHP v2.3.2
You can use this:
For Cake 2.0, the query log is protected so this will work