Skip to content

Commit edc8522

Browse files
author
liu21st@gmail.com
committed
增加DB_SQL_LOG配置参数 用于配色是否记录sql日志(但仍然受LOG_LEVEL影响)
并废除Db类的debug属性 sql日志记录不再受项目的调试模式影响 git-svn-id: http://thinkphp.googlecode.com/svn/trunk@2970 539fd3ec-2725-0410-b7ab-251e373a8e33
1 parent 75863c8 commit edc8522

File tree

6 files changed

+7
-9
lines changed

6 files changed

+7
-9
lines changed

ThinkPHP/Common/runtime.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
define('THINK_RELEASE', '20120323');
2424

2525
// 系统信息
26-
if(version_compare(PHP_VERSION,'5.3.0','<') ) {
27-
set_magic_quotes_runtime (0);
26+
if(version_compare(PHP_VERSION,'5.3.0','<')) {
27+
set_magic_quotes_runtime(0);
2828
define('MAGIC_QUOTES_GPC',get_magic_quotes_gpc()?True:False);
2929
}else{
3030
define('MAGIC_QUOTES_GPC',True);

ThinkPHP/Conf/convention.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
'DB_SQL_BUILD_CACHE' => false, // 数据库查询的SQL创建缓存
7272
'DB_SQL_BUILD_QUEUE' => 'file', // SQL缓存队列的缓存方式 支持 file xcache和apc
7373
'DB_SQL_BUILD_LENGTH' => 20, // SQL缓存的队列长度
74+
'DB_SQL_LOG' => false, // SQL执行日志记录
7475

7576
/* 数据缓存设置 */
7677
'DATA_CACHE_TIME'=> 0, // 数据缓存有效期 0表示永久缓存

ThinkPHP/Lib/Core/Db.class.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ class Db {
2626
protected $dbType = null;
2727
// 是否自动释放查询结果
2828
protected $autoFree = false;
29-
// 是否显示调试信息 如果启用会在日志文件记录sql语句
30-
public $debug = false;
3129
// 当前操作所属的模型名
3230
protected $model = '_think_';
3331
// 是否使用永久连接
@@ -110,7 +108,6 @@ public function factory($db_config='') {
110108
$db->dbType = strtoupper($this->dbType);
111109
else
112110
$db->dbType = $this->_getDsnType($db_config['dsn']);
113-
if(APP_DEBUG) $db->debug = true;
114111
}else {
115112
// 类没有定义
116113
throw_exception(L('_NO_DB_DRIVER_').': ' . $class);
@@ -301,7 +298,7 @@ protected function debug() {
301298
$this->modelSql[$this->model] = $this->queryStr;
302299
$this->model = '_think_';
303300
// 记录操作结束时间
304-
if ( $this->debug ) {
301+
if (C('DB_SQL_LOG')) {
305302
G('queryEndTime');
306303
Log::record($this->queryStr.' [ RunTime:'.G('queryStartTime','queryEndTime',6).'s ]',Log::SQL);
307304
}

ThinkPHP/Lib/Core/Think.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ static public function appError($errno, $errstr, $errfile, $errline) {
282282

283283
// 致命错误捕获
284284
static public function fatalError() {
285-
if ($e = error_get_last()) {
285+
if ($e = error_get_last()) {
286286
Think::appError($e['type'],$e['message'],$e['file'],$e['line']);
287287
}
288288
}

ThinkPHP/Lib/Driver/Db/DbMysql.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ public function close() {
386386
*/
387387
public function error() {
388388
$this->error = mysql_error($this->_linkID);
389-
if($this->debug && '' != $this->queryStr){
389+
if('' != $this->queryStr){
390390
$this->error .= "\n [ SQL语句 ] : ".$this->queryStr;
391391
}
392392
Log::record($this->error,Log::ERR);

ThinkPHP/Lib/Driver/Db/DbMysqli.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ public function close() {
380380
*/
381381
public function error() {
382382
$this->error = $this->_linkID->error;
383-
if($this->debug && '' != $this->queryStr){
383+
if('' != $this->queryStr){
384384
$this->error .= "\n [ SQL语句 ] : ".$this->queryStr;
385385
}
386386
Log::record($this->error,Log::ERR);

0 commit comments

Comments
 (0)