echo $this->element('sql_dump'); without debug and in a mail
cakephp
Solution
To get debugging info when debug mode is 0 you have to manipulate the data source before executing your query.
In your controller:
$db = $this->MyModel->getDataSource();
$db->fullDebug = true;
$this->MyModel->find(...);
$log = $db->getLog();
$db->fullDebug = false;
// email yourself the log
Problem
In CAKEPHP the function `$this->element('sql_dump')` prints the executed sql querys on the screen. `$this->element('sql_dump')` is only available with `debug mode = 2` This works fine but I would like the following to work: - Debug mode has to be 0 - I do not want to `echo` the sql dump on the screen but mail it to myself - This has to happen with the click on a button (send bug report) Is this possible, how? Thanks for you help