How can I see CakePHP's SQL dump in the controller?

后端 未结 8 1247
余生分开走
余生分开走 2020-12-04 06:04

Is there a way that one can cause CakePHP to dump its SQL log on demand? I\'d like to execute code up until a point in my controller and see what SQL has been run.

8条回答
  •  借酒劲吻你
    2020-12-04 06:46

    If you're using CakePHP 1.3, you can put this in your views to output the SQL:

    element('sql_dump'); ?>
    

    So you could create a view called 'sql', containing only the line above, and then call this in your controller whenever you want to see it:

    $this->render('sql');
    

    (Also remember to set your debug level to at least 2 in app/config/core.php)

    Source

提交回复
热议问题