This commit is contained in:
2021-11-10 02:28:08 +08:00
parent 7400b27cb9
commit 606cf7a722
2 changed files with 4 additions and 2 deletions
+1
View File
@@ -169,6 +169,7 @@ class Command extends Component
$pdo = $this->db->getConnect($this->sql);
$result = $pdo->execute($this->sql, $isInsert, $this->params);
if ($hasAutoIncrement && $result == 0) {
var_dump($hasAutoIncrement, $result);
return false;
}
return $result;
+3 -2
View File
@@ -250,7 +250,8 @@ class PDO implements StopHeartbeatCheck
public function execute(string $sql, $isInsert, array $params = []): int
{
$this->_last = time();
if (!(($prepare = $this->_pdo()->prepare($sql)) instanceof PDOStatement)) {
$pdo = $this->_pdo();
if (!(($prepare = $pdo->prepare($sql)) instanceof PDOStatement)) {
throw new Exception($prepare->errorInfo()[2] ?? static::DB_ERROR_MESSAGE);
}
if ($prepare->execute($params) === false) {
@@ -258,7 +259,7 @@ class PDO implements StopHeartbeatCheck
}
$result = 1;
if ($isInsert) {
$result = (int)$this->_pdo()->lastInsertId();
$result = (int)$pdo->lastInsertId();
}
$prepare->closeCursor();
return $result;