mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
改进数据库驱动类的异常处理
This commit is contained in:
@@ -160,15 +160,21 @@ abstract class Driver {
|
||||
}
|
||||
}
|
||||
$this->bind = [];
|
||||
$result = $this->PDOStatement->execute();
|
||||
// 调试结束
|
||||
$this->debug(false);
|
||||
if ( false === $result ) {
|
||||
try{
|
||||
$result = $this->PDOStatement->execute();
|
||||
// 调试结束
|
||||
$this->debug(false);
|
||||
if ( false === $result ) {
|
||||
$this->error();
|
||||
return false;
|
||||
} else {
|
||||
return $this->getResult();
|
||||
}
|
||||
}catch (\PDOException $e) {
|
||||
$this->error();
|
||||
return false;
|
||||
} else {
|
||||
return $this->getResult();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -207,18 +213,24 @@ abstract class Driver {
|
||||
}
|
||||
}
|
||||
$this->bind = [];
|
||||
$result = $this->PDOStatement->execute();
|
||||
$this->debug(false);
|
||||
if ( false === $result) {
|
||||
try{
|
||||
$result = $this->PDOStatement->execute();
|
||||
$this->debug(false);
|
||||
if ( false === $result) {
|
||||
$this->error();
|
||||
return false;
|
||||
} else {
|
||||
$this->numRows = $this->PDOStatement->rowCount();
|
||||
if(preg_match("/^\s*(INSERT\s+INTO|REPLACE\s+INTO)\s+/i", $str)) {
|
||||
$this->lastInsID = $this->_linkID->lastInsertId();
|
||||
}
|
||||
return $this->numRows;
|
||||
}
|
||||
}catch (\PDOException $e) {
|
||||
$this->error();
|
||||
return false;
|
||||
} else {
|
||||
$this->numRows = $this->PDOStatement->rowCount();
|
||||
if(preg_match("/^\s*(INSERT\s+INTO|REPLACE\s+INTO)\s+/i", $str)) {
|
||||
$this->lastInsID = $this->_linkID->lastInsertId();
|
||||
}
|
||||
return $this->numRows;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user