<?php
return array(
// …
'components' => array(
// …
'db' => array(
// …
'enableProfiling'=>true,
'enableParamLogging' => true,
),
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
// …
array(
'class'=>'ext.db_profiler.DbProfileLogRoute',
'countLimit' => 1, // How many times the same query should be executed to be considered inefficient
'slowQueryMin' => 0.01, // Minimum time for the query to be slow
),
),
),
),
);
3条答案
按热度按时间qvtsj1bj1#
正如@ bool.dev所说,您可以使用
CWebLogRoute
,或者在我的情况下,我使用CFileLogRoute
将这些查询存储在文件中。yqhsw0fo2#
为了补充@snippLeaf-com的答案,您可以通过所需的关键字跟踪此文件过滤,如下所示:
OBS:要获取最新数据,您可能需要刷新数据库缓存:
lrpiutwd3#
如果你真的希望每个查询日志都在yii中使用yii db profiler扩展名。
步骤1.从--〉link下载扩展
步骤2.打开 Package 至
protected/extensions/
步骤3.将文件夹名称
yii-db-profiler-master
重命名为db_profiler
步骤4.将以下内容更新到您得
protected/config/main.php
: