这篇文章主要介绍了yii框架在页面输出执行sql语句以方便调试的实现方法,涉及yiidebugtb的使用,是比较实用的技巧,需要的朋友可以参考下
本文实例讲述了Yii框架在页面输出执行sql语句以方便调试的实现方法。分享给大家供大家参考。具体分析如下:
我们使用:yiidebugtb来调试(因为用他界面比较美观,不影响界面其他元素)。
1.下载yiidebugtb,并且放入到 application.extensions.yiidebugtb 目录
2.修改main.php,加入如下代码:
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class'=>'CFileLogRoute',
'levels'=>'error, warning,trace',
),
// 以下是新加
array( // configuration for the toolbar
'class'=>'XWebDebugRouter',
'config'=>'alignLeft, opaque, runInDebug, fixedPos, collapsed, yamlStyle',
'levels'=>'error, warning, trace, profile, info',
//'categories' => 'system.db.*',
'allowedIPs'=>array('127.0.0.1','::1','192\.168\.1[0-5]\.[0-9]{3}','如果程序在外网需要填入你的公网的ip'),
),
),
)3.db链接的配置里面做下修改:
'db'=>array(
'connectionString'=>'mysql:host=*.*.*.*;dbname=test',
'emulatePrepare'=>true, // 加入
'enableParamLogging' => true, // 加入
'username'=>'-----',
'password'=>'---',
'charset'=>'utf8',
'schemaCachingDuration'=>'0',
'autoConnect'=>false,
),4.运行效果如下图所示:

以上就是本文的全部内容,希望对大家的学习有所帮助,更多相关内容请关注PHP中文网!
相关推荐:
如何实现Yii2框架中使用PHPExcel导出Excel文件
以上就是如何实现Yii框架在页面输出执行sql语句并进行调试的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号