改进数据库驱动类的异常处理

This commit is contained in:
thinkphp
2015-05-07 11:58:47 +08:00
parent 33eed33826
commit 979b6a2d3e

View File

@@ -160,6 +160,7 @@ abstract class Driver {
} }
} }
$this->bind = []; $this->bind = [];
try{
$result = $this->PDOStatement->execute(); $result = $this->PDOStatement->execute();
// 调试结束 // 调试结束
$this->debug(false); $this->debug(false);
@@ -169,6 +170,11 @@ abstract class Driver {
} else { } else {
return $this->getResult(); return $this->getResult();
} }
}catch (\PDOException $e) {
$this->error();
return false;
}
} }
/** /**
@@ -207,6 +213,7 @@ abstract class Driver {
} }
} }
$this->bind = []; $this->bind = [];
try{
$result = $this->PDOStatement->execute(); $result = $this->PDOStatement->execute();
$this->debug(false); $this->debug(false);
if ( false === $result) { if ( false === $result) {
@@ -219,6 +226,11 @@ abstract class Driver {
} }
return $this->numRows; return $this->numRows;
} }
}catch (\PDOException $e) {
$this->error();
return false;
}
} }
/** /**