欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Yii調(diào)試SQL的常用方法

 更新時(shí)間:2014年07月09日 17:00:09   投稿:shichen2014  
這篇文章主要介紹了Yii調(diào)試SQL的常用方法,需要的朋友可以參考下

Yii調(diào)試SQL主要有以下方法:

一、系統(tǒng)自帶調(diào)試:

首先index.php開啟調(diào)試模式:

// remove the following lines when in production mode 
defined('YII_DEBUG') or define('YII_DEBUG',true); 
// specify how many levels of call stack should be shown in each log message 
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3); 
//app use time 
//defined('YII_BEGIN_TIME') or define('YII_BEGIN_TIME',microtime(true));

main.php頁(yè)面:

'errorHandler'=>array( 
  // use 'site/error' action to display errors 
  'errorAction'=>'site/error', 
), 
'log'=>array( 
  'class'=>'CLogRouter', 
  'routes'=>array( 
    array( 
      'class'=>'CFileLogRoute', 
      'levels'=>'error, warning', 
    ), 
    // 下面顯示頁(yè)面日志 
    array( 
      'class'=>'CWebLogRoute', 
      'levels'=>'trace',   //級(jí)別為trace 
      'categories'=>'system.db.*' //只顯示關(guān)于數(shù)據(jù)庫(kù)信息,包括數(shù)據(jù)庫(kù)連接,數(shù)據(jù)庫(kù)執(zhí)行語(yǔ)句 
    ),    
  ), 
),

YII_TRACE_LEVEL的數(shù)字越大,信息越清楚

二、使用調(diào)試工具調(diào)試:

yii-debug-toolbar把包解壓后 放到extensions里邊 然后在配置文件main.php中最后加上

'log'=>array( 
   'class'=>'CLogRouter', 
   'routes'=>array( 
     array( 
       'class'=>'ext.yii-debug-toolbar.YiiDebugToolbarRoute', 
       'ipFilters'=>array('127.0.0.1','192.168.1.215'), 
     ), 
   ), 
 ),

沒有出現(xiàn)的話加上在'components'下的db里加上兩個(gè)屬性,

'enableProfiling'=>true, 
'enableParamLogging'=>true,

然后如果有其他調(diào)試工具的插件的話,可能會(huì)出現(xiàn)沖突導(dǎo)致sql語(yǔ)句不出來(lái),把那段代碼注掉即可。

相關(guān)文章

最新評(píng)論