diff --git a/src/Command.php b/src/Command.php index 5082537..98f700e 100644 --- a/src/Command.php +++ b/src/Command.php @@ -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; diff --git a/src/Mysql/PDO.php b/src/Mysql/PDO.php index 6c42f25..ad92347 100644 --- a/src/Mysql/PDO.php +++ b/src/Mysql/PDO.php @@ -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;