We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 407cd67 commit a35bcefCopy full SHA for a35bcef
src/database/src/AbstractConnection.php
@@ -193,7 +193,12 @@ public function execute(): ConnectionInterface
193
$this->sqlData[3] = $time;
194
195
// 缓存常用数据,让资源可以提前回收
196
- if (!isset($ex) && ($this->driver->pool && !$this instanceof Transaction)) {
+ if (isset($ex)) {
197
+ // 有异常: 使用默认值, 不调用 driver, statement
198
+ $this->lastInsertId = '';
199
+ $this->rowCount = 0;
200
+ } elseif ($this->driver->pool && !$this instanceof Transaction) {
201
+ // 有pool: 提前缓存 lastInsertId, rowCount 让连接提前归还
202
try {
203
if (stripos($this->sql, 'INSERT INTO') !== false) {
204
$this->lastInsertId = $this->driver->instance()->lastInsertId();
0 commit comments