Skip to content

Commit 94f9259

Browse files
committed
数据库驱动类error方法添加错误代码输出
1 parent 6686739 commit 94f9259

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

Extend/Driver/Db/DbIbase.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ public function close() {
299299
* @return string
300300
*/
301301
public function error() {
302-
$this->error = ibase_errmsg();
302+
$this->error = ibase_errcode().':'.ibase_errmsg();
303303
if('' != $this->queryStr){
304304
$this->error .= "\n [ SQL语句 ] : ".$this->queryStr;
305305
}

Extend/Driver/Db/DbPdo.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ public function close() {
391391
public function error() {
392392
if($this->PDOStatement) {
393393
$error = $this->PDOStatement->errorInfo();
394-
$this->error = $error[2];
394+
$this->error = $error[1].':'.$error[2];
395395
}else{
396396
$this->error = '';
397397
}

Extend/Driver/Db/DbSqlite.class.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,8 @@ public function close() {
246246
* @return string
247247
*/
248248
public function error() {
249-
$this->error = sqlite_error_string(sqlite_last_error($this->_linkID));
249+
$code = sqlite_last_error($this->_linkID);
250+
$this->error = $code.':'.sqlite_error_string($code);
250251
if('' != $this->queryStr){
251252
$this->error .= "\n [ SQL语句 ] : ".$this->queryStr;
252253
}

Extend/Driver/Db/DbSqlsrv.class.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,12 +319,12 @@ public function error($result = true) {
319319
$errors = sqlsrv_errors();
320320
$this->error = '';
321321
foreach( $errors as $error ) {
322-
$this->error .= $error['message'];
322+
$this->error .= $error['code'].':'.$error['message'];
323323
}
324324
if('' != $this->queryStr){
325325
$this->error .= "\n [ SQL语句 ] : ".$this->queryStr;
326326
}
327-
$result? trace($error['message'],'','ERR'):throw_exception($this->error);
327+
$result? trace($this->error,'','ERR'):throw_exception($this->error);
328328
return $this->error;
329329
}
330330
}

0 commit comments

Comments
 (0)