Skip to content

Commit 3f34fd4

Browse files
author
liu21st@gmail.com
committed
废除扩展db驱动里面的debug属性相关代码
git-svn-id: http://thinkphp.googlecode.com/svn/trunk@2972 539fd3ec-2725-0410-b7ab-251e373a8e33
1 parent 06a5084 commit 3f34fd4

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

Extend/Driver/Db/DbIbase.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ public function close() {
365365
*/
366366
public function error() {
367367
$this->error = ibase_errmsg();
368-
if($this->debug && '' != $this->queryStr){
368+
if('' != $this->queryStr){
369369
$this->error .= "\n [ SQL语句 ] : ".$this->queryStr;
370370
}
371371
Log::record($this->error,Log::ERR);

Extend/Driver/Db/DbMongo.class.php

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function switchCollection($collection,$db='',$master=true){
9494
$this->_mongo = $this->_linkID->selectDb($db);
9595
}
9696
// 当前MongoCollection对象
97-
if($this->debug) {
97+
if(C('DB_SQL_LOG')) {
9898
$this->queryStr = $this->_dbName.'.getCollection('.$collection.')';
9999
}
100100
if($this->_collectionName != $collection) {
@@ -203,6 +203,7 @@ public function close() {
203203
*/
204204
public function error() {
205205
$this->error = $this->_mongo->lastError();
206+
Log::record($this->error,Log::ERR);
206207
return $this->error;
207208
}
208209

@@ -225,7 +226,7 @@ public function insert($data,$options=array(),$replace=false) {
225226
}
226227
$this->model = $options['model'];
227228
N('db_write',1);
228-
if($this->debug) {
229+
if(C('DB_SQL_LOG')) {
229230
$this->queryStr = $this->_dbName.'.'.$this->_collectionName.'.insert(';
230231
$this->queryStr .= $data?json_encode($data):'{}';
231232
$this->queryStr .= ')';
@@ -290,7 +291,7 @@ public function insertAll($dataList,$options=array()) {
290291
*/
291292
public function mongo_next_id($pk) {
292293
N('db_read',1);
293-
if($this->debug) {
294+
if(C('DB_SQL_LOG')) {
294295
$this->queryStr = $this->_dbName.'.'.$this->_collectionName.'.find({},{'.$pk.':1}).sort({'.$pk.':-1}).limit(1)';
295296
}
296297
try{
@@ -325,7 +326,7 @@ public function update($data,$options) {
325326
N('db_write',1);
326327
$query = $this->parseWhere($options['where']);
327328
$set = $this->parseSet($data);
328-
if($this->debug) {
329+
if(C('DB_SQL_LOG')) {
329330
$this->queryStr = $this->_dbName.'.'.$this->_collectionName.'.update(';
330331
$this->queryStr .= $query?json_encode($query):'{}';
331332
$this->queryStr .= ','.json_encode($set).')';
@@ -359,7 +360,7 @@ public function delete($options=array()) {
359360
$query = $this->parseWhere($options['where']);
360361
$this->model = $options['model'];
361362
N('db_write',1);
362-
if($this->debug) {
363+
if(C('DB_SQL_LOG')) {
363364
$this->queryStr = $this->_dbName.'.'.$this->_collectionName.'.remove('.json_encode($query).')';
364365
}
365366
try{
@@ -390,7 +391,7 @@ public function clear($options=array()){
390391
}
391392
$this->model = $options['model'];
392393
N('db_write',1);
393-
if($this->debug) {
394+
if(C('DB_SQL_LOG')) {
394395
$this->queryStr = $this->_dbName.'.'.$this->_collectionName.'.remove({})';
395396
}
396397
try{
@@ -432,7 +433,7 @@ public function select($options=array()) {
432433
$query = $this->parseWhere($options['where']);
433434
$field = $this->parseField($options['field']);
434435
try{
435-
if($this->debug) {
436+
if(C('DB_SQL_LOG')) {
436437
$this->queryStr = $this->_dbName.'.'.$this->_collectionName.'.find(';
437438
$this->queryStr .= $query? json_encode($query):'{}';
438439
$this->queryStr .= $field? ','.json_encode($field):'';
@@ -443,7 +444,7 @@ public function select($options=array()) {
443444
$_cursor = $this->_collection->find($query,$field);
444445
if($options['order']) {
445446
$order = $this->parseOrder($options['order']);
446-
if($this->debug) {
447+
if(C('DB_SQL_LOG')) {
447448
$this->queryStr .= '.sort('.json_encode($order).')';
448449
}
449450
$_cursor = $_cursor->sort($order);
@@ -462,12 +463,12 @@ public function select($options=array()) {
462463
if(isset($options['limit'])) {
463464
list($offset,$length) = $this->parseLimit($options['limit']);
464465
if(!empty($offset)) {
465-
if($this->debug) {
466+
if(C('DB_SQL_LOG')) {
466467
$this->queryStr .= '.skip('.intval($offset).')';
467468
}
468469
$_cursor = $_cursor->skip(intval($offset));
469470
}
470-
if($this->debug) {
471+
if(C('DB_SQL_LOG')) {
471472
$this->queryStr .= '.limit('.intval($length).')';
472473
}
473474
$_cursor = $_cursor->limit(intval($length));
@@ -511,7 +512,7 @@ public function find($options=array()){
511512
N('db_query',1);
512513
$query = $this->parseWhere($options['where']);
513514
$fields = $this->parseField($options['field']);
514-
if($this->debug) {
515+
if(C('DB_SQL_LOG')) {
515516
$this->queryStr = $this->_dbName.'.'.$this->_collectionName.'.findOne(';
516517
$this->queryStr .= $query?json_encode($query):'{}';
517518
$this->queryStr .= $fields?','.json_encode($fields):'';
@@ -549,7 +550,7 @@ public function count($options=array()){
549550
$this->model = $options['model'];
550551
N('db_query',1);
551552
$query = $this->parseWhere($options['where']);
552-
if($this->debug) {
553+
if(C('DB_SQL_LOG')) {
553554
$this->queryStr = $this->_dbName.'.'.$this->_collectionName;
554555
$this->queryStr .= $query?'.find('.json_encode($query).')':'';
555556
$this->queryStr .= '.count()';
@@ -583,7 +584,7 @@ public function getFields($collection=''){
583584
$this->switchCollection($collection,'',false);
584585
}
585586
N('db_query',1);
586-
if($this->debug) {
587+
if(C('DB_SQL_LOG')) {
587588
$this->queryStr = $this->_dbName.'.'.$this->_collectionName.'.findOne()';
588589
}
589590
try{
@@ -616,7 +617,7 @@ public function getFields($collection=''){
616617
+----------------------------------------------------------
617618
*/
618619
public function getTables(){
619-
if($this->debug) {
620+
if(C('DB_SQL_LOG')) {
620621
$this->queryStr = $this->_dbName.'.getCollenctionNames()';
621622
}
622623
N('db_query',1);

0 commit comments

Comments
 (0)