[CakePHP1.3.3]
When you debug, within Controller and Model there is often something like SQL from the instant you’ve done $this->find().
At that time, either put the function below into vendor or if you read it in bootstrap you can confirm it in SQL any time.
Incidentally, within Shell things stripped of HTML are output so it’s very convenient.
When you set Configure::write(‘debug’, 2) or higher, it works.
function sql_dump($dbConfig = 'default', $exit = true) {
ConnectionManager::getDataSource($dbConfig)->showLog();
if ($exit) { exit; }
}
How to use it is as seen below.
class SampleShell extends Shell {
public $uses = array('Sample');
public function main() {
$this->Sample->find('all');
sql_dump();
}
}
3 Comments
I agree with the post above and I will find more information from google.
Very useful information. Specially debugging in shell script.
Thanks for this. Helped me out in debugging a shell.
One Trackback
[...] This post was mentioned on Twitter by Masaya Iwata, Masaya Iwata. Masaya Iwata said: Blog Updates, How to check SQL queries in Shell and Controller http://bit.ly/9AecmG [...]