search
Homephp教程php手册Yii框架在页面输出执行sql语句以方便调试的实现方法,yiisql

Yii框架在页面输出执行sql语句以方便调试的实现方法,yiisql

本文实例讲述了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.运行效果如下图所示:

希望本文所述对大家基于Yii框架的php程序设计有所帮助。

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)