mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 07:12:47 +08:00
改进数据库驱动类的异常处理
This commit is contained in:
@@ -160,15 +160,21 @@ abstract class Driver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->bind = [];
|
$this->bind = [];
|
||||||
$result = $this->PDOStatement->execute();
|
try{
|
||||||
// 调试结束
|
$result = $this->PDOStatement->execute();
|
||||||
$this->debug(false);
|
// 调试结束
|
||||||
if ( false === $result ) {
|
$this->debug(false);
|
||||||
|
if ( false === $result ) {
|
||||||
|
$this->error();
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return $this->getResult();
|
||||||
|
}
|
||||||
|
}catch (\PDOException $e) {
|
||||||
$this->error();
|
$this->error();
|
||||||
return false;
|
return false;
|
||||||
} else {
|
|
||||||
return $this->getResult();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -207,18 +213,24 @@ abstract class Driver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->bind = [];
|
$this->bind = [];
|
||||||
$result = $this->PDOStatement->execute();
|
try{
|
||||||
$this->debug(false);
|
$result = $this->PDOStatement->execute();
|
||||||
if ( false === $result) {
|
$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();
|
$this->error();
|
||||||
return false;
|
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