20
22

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[CakePHP2] find時のSQLをログに出力

Last updated at Posted at 2016-03-31

CakePHPでfind時のSQLをログに出力

find実行した後に書きを記述


$this->log( $this->{モデル名}->getDataSource()->getLog(), LOG_DEBUG);
  • LOG_DEBUG: app/tmp/logs/debug.log
  • 省略時: app/tmp/logs/error.log

画面に出すなら


pr( $this->{モデル名}->getDataSource()->getLog() );

var_dump( $this->{モデル名}->getDataSource()->getLog() );

とか。

※ 注意:デバッグレベル 2以上でないと、出力されない
core.php(baserCMSの場合は install.php)に Configure::write('debug', 2); または Configure::write('debug', 3); を記述する必要あり

20
22
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
20
22

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?