可以通过配置相关文件来实现,具体方法如下:
(1)修改 index.php 开启调试模式
在 index.php 文件内增加如下两行代码(如果不存在的话):
1 //开启调试模式 2 defined('yii_debug') or define('yii_debug',true); 3 //设置日志记录级别,yii_trace_level的数字越大,信息越清楚 4 defined('yii_trace_level') or define('yii_trace_level',3);
(推荐教程:yii框架)
(2)修改配置文件 main.php
在config/main.php的 components - log - routes 下加入如下数组:
1 array( 2 'class'=>'cfilelogroute',//文件记录日志的形式 3 'levels'=>'trace',//日志记录级别 4 'categories'=>'system.db.*',//只显示关于数据库信息,包括数据库连接,数据库执行语句 5 'logfile' => 'app_'.date('y-m-d').'.log',//日志保存文件名 6 'logpath'=>'d:\phpstudy\www\phpernote\com\tmpfile\log_db',//日志保存路径 7 ),
经过如上的设置,刷新页面,你就可以到 d:\phpstudy\www\phpernote\com\tmpfile\log_db 这个目录里面去查找生成的sql记录文件了。
更多编程相关内容,请关注编程入门栏目!
以上就是yii如何查看当前页面执行的sql语句的详细内容。