Home  >  Article  >  Backend Development  >  Yii framework, output and execute sql statements on the page to facilitate debugging, yiisql_PHP tutorial

Yii framework, output and execute sql statements on the page to facilitate debugging, yiisql_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:11:09959browse

The Yii framework outputs and executes sql statements on the page to facilitate debugging. yiisql

We use: yiidebugtb for debugging (because the interface is more beautiful and does not affect other elements of the interface).

1. Download yiidebugtb and put it into the application.extensions.yiidebugtb directory

2. Modify main.php and add the following code:

        'log'=><span>array</span><span>(
            </span>'class'=>'CLogRouter',
            'routes'=><span>array</span><span>(
                </span><span>array</span><span>(
                    </span>'class'=>'CFileLogRoute',
                    'levels'=>'error, warning,trace',<span>
                )</span>,<br />
                <span>//</span><span> 以下是新加</span>
                <span>array</span>( <span>//</span><span> configuration for the toolbar</span>
                    'class'=>'XWebDebugRouter',
                    'config'=>'alignLeft, opaque, runInDebug, fixedPos, collapsed, yamlStyle',
                    'levels'=>'error, warning, trace, profile, info',
                    <span>//</span><span>'categories' => 'system.db.*',</span>
                    'allowedIPs'=><span>array</span>('127.0.0.1','::1','192\.168\.1[0-5]\.[0-9]{3}','如果程序在外网需要填入你的公网的ip'),<span>
                  )</span>,<span>
                
            )</span>,<span>
        )</span>

Make the following changes in the configuration of 3.db link:

        'db'=><span>array</span><span>(
            </span>'connectionString'=>'mysql:host=*.*.*.*;dbname=test',
            <strong>'emulatePrepare'=><span>true</span></strong>,   <span>//</span><span> 加入</span>
            <strong>'enableParamLogging' => <span>true</span></strong>, <span>//</span><span> 加入</span> 
            'username'=>'-----',
            'password'=>'---',
            'charset'=>'utf8',
            'schemaCachingDuration'=>'0',
            'autoConnect'=><span>false</span>,<span>
        )</span>,

4. Complete

For example:

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/931387.htmlTechArticleYii framework, output and execute sql statements on the page to facilitate debugging, yiisql we use: yiidebugtb for debugging (because he uses The interface is more beautiful and does not affect other elements of the interface). 1. Download y...
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