Reputation: 521
Is there any way to see the query being executed by a CDbCriteria?
Upvotes: 0
Views: 186
Reputation: 3322
I personally use this in my config file protected/config/main.php
// SQL Commands
array(
'class'=>'CFileLogRoute',
'maxFileSize' => 30720,
'maxLogFiles' => 10,
'rotateByCopy' => true,
'levels'=>'trace,info,error,warning',
'logFile'=>'sql.log',
'categories'=>'system.db.CDbCommand'
),
Reference: http://www.yiiframework.com/doc/guide/1.1/en/topics.logging
Notice categories
index: http://www.yiiframework.com/doc/api/1.1/CLogRoute#categories-detail
array of categories, or string list separated by comma or space. Defaults to empty array, meaning all categories.
CDbCriteria
doesn't execute queries itself, it is passed to other classes like CActiveDataProvider
or methods like find()
, etc which calls CDbCommand
in the end. So we log only that category.
I am not that good with terminology, hope you got it.
Upvotes: 1