This article mainly introduces how Yii Framework outputs and executes SQL statements on pages to facilitate debugging. it is a practical technique involving the use of yiidebugtb, for more information about how to debug the Yii Framework, see the following example. Share it with you for your reference. The specific analysis is as follows:
We use: yiidebugtb for debugging (because its interface is more beautiful and does not affect other elements on the interface ).
1. download yiidebugtb and put it in the application. extensions. yiidebugtb directory.
2. modify main. php and add the following code:
The code is as follows:
'Log' => array (
'Class' => 'clogrouter ',
'Routes '=> array (
Array (
'Class' => 'cfilelogroute ',
'Levels' => 'Error, warning, Track ',
),
// The following is the new addition
Array (// configuration for the toolbar
'Class' => 'xwebdebugrouter ',
'Config' => 'alignleft, opaque, runInDebug, fixedPos, collapsed, yamlstyle ',
'Levels' => 'Error, warning, trace, profile, info ',
// 'Category' => 'system. db .*',
'Allowedips' => array ('2017. 0.0.1 ',': 1', '192 \. 168 \. 1 [0-5] \. [0-9] {3} ', 'fill in your public ip address if the program is on the extranet '),
),
),
)
3. modify the configuration of the db link:
The code is as follows:
'DB' => array (
'Connectionstring' => 'MySQL: host = *. *; dbname = test ',
'Default' => true, // add
'Enablesparamlogging' => true, // add
'Username' => '-----',
'Password' => '---',
'Charset' => 'utf8 ',
'Schemacachingduration' => '0 ',
'Autoconnect '=> false,
),
4. shows the running effect:
I hope this article will help you design php programs based on the Yii Framework.