ThinkPHP学習ノート(四)デバッグモードとログ記録

2474 ワード

派手な分割線の下には、修正と構成が必要な具体的な実装方法があります.
cong.php
<?php
return array(

//          ~app.php ~runtime.php

//'   '=>'   '
//    URL                ,           
//     rewrite  ,       
//1.query        Apache rewrite  
//	LoadModule rewrite_module modules/mod_rewrite.so
//2.       ,     ,    .htaccess(vi:save .htaccess;   :".htaccess")
//      2(rewrite)         
'URL_MODEL'=>1,

'URL_PATNINFO_MODEL'=>2,
//pathinfo    
	//1    :  m a:          
	//http://localhost/MyThinkPHP/admin.php/m/index/a/index
	//  
	//http://localhost/MyThinkPHP/admin.php/m/index/a/index/username/zhangsan/password/password
	//2        (          )
	//http://localhost/MyThinkPHP/admin.php/index/index
	//  
	//http://localhost/MyThinkPHP/admin.php/index/index/username/zhangsan/password/password
		

//  URL   
//'URL_PATHINFO_DEPR'=>'-',

//         
'TMPL_L_DELIM'=>'<!--{',
'TMPL_R_DELIM'=>'}-->',


//********************************        **************************************

//      
//1.  linux        
//2.                 
'APP_DEBUG'=>true,
//        Trace  
//       Trace     Thinkphp/Tpl  pageTrace.tpl.php
//     :
//'TMPL_TRACE_FILE'=>APP_PATH.'/Public/trace.php',
//      trace.php       Conf    

//         :
//ThinkPHP/Common/debug.php
//        ;    ,      Runtim/Data         
//'DB_FIELDS_CACHE'=> false,
//      debug.php     Conf    

//  APP_DEBUG   false         
//'APP_DEBUG'=>false,
//             
//'SHOW_RUN_TIME'=>true,
//         (  SHOW_RUN_TIME)
//'SHOW_ADV_TIME'=>true,
//          (  SHOW_RUN_TIME)
//'SHOW_DB_TIMES'=>true,
//         (  SHOW_RUN_TIME)
//'SHOW_CACHE_TIMES'=>true,
//       (  SHOW_RUN_TIME)
//'SHOW_USE_MEM'=>true,



//    
//'DEFAULT_THEME'=>'default',



//    log :lib/Think/Core/log.class.php
//    
'LOG_RECORD'=>true,
//    log :lib/Think/Core/log.class.php      ,        
'LOG_RECORD_LEVEL'=>array('EMERG','ALERT'),

);
?>

アクションで使用する:
        
//    (           )
$User=new Model('User');
$User->find(1);
//         sql
echo $User->getLastSql();

//  :    、    、    、    
Log::write("aa",$level,$type,$file);
//record