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

后端 未结 8 1267
余生分开走
余生分开走 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:28

    Try this:

    $log = $this->Model->getDataSource()->getLog(false, false);
    debug($log);
    

    http://api.cakephp.org/2.3/class-Model.html#_getDataSource

    You will have to do this for each datasource if you have more than one though.

提交回复
热议问题