Yii Framework 開啓調試模式

轉自:http://www.eeice.com/archive/design/yii-sqldebug.html

更改配置文件:{config/main.php}

'db'=>array(
            'connectionString' => 'mysql:host=localhost;dbname=test_try',
            'emulatePrepare' => true,
            'username' => 'boy_test',
            'password' => 'password',
            'charset' => 'utf8',
//////////////////////////////////////////////////////增加
            'enableProfiling'=>YII_DEBUG,
            'enableParamLogging'=>YII_DEBUG,
/////////////////////////////////////////////////////
        ),
 
'log'=>array(
            'class'=>'CLogRouter',
            'routes'=>array(
                array(
                    'class'=>'CFileLogRoute',
                    'levels'=>'error, warning',
                ),
                // uncomment the following to show log messages on web pages
//////////////////////////////////////////////////////增加
                array(
                    'class'=>'CWebLogRoute',
                    'levels'=>'trace',//提示的級別
                    'categories'=>'system.db.*',
//還可以通過 'showInFireBug'=>true, //顯示在Firebug裏
//顯示在Firebug裏我們就可以調整提示級別,來顯示更多
//例如'levels'=>'trace,info,error,warning,xdebug',
                ), 
//////////////////////////////////////////////////////
             ),
         ),

以上代碼會在也腳顯示執行的sql語句,如果把 'categories'=>'system.db.*',,替換爲 'categories'=>'system.*',,則會顯示所有系統執行過程。


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章