mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 23:22:48 +08:00
改进短线重连异常捕获机制
This commit is contained in:
@@ -354,15 +354,15 @@ abstract class Connection
|
|||||||
$this->bind = $bind;
|
$this->bind = $bind;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 释放前次的查询结果
|
|
||||||
if (!empty($this->PDOStatement)) {
|
|
||||||
$this->free();
|
|
||||||
}
|
|
||||||
|
|
||||||
Db::$queryTimes++;
|
Db::$queryTimes++;
|
||||||
try {
|
try {
|
||||||
// 调试开始
|
// 调试开始
|
||||||
$this->debug(true);
|
$this->debug(true);
|
||||||
|
|
||||||
|
// 释放前次的查询结果
|
||||||
|
if (!empty($this->PDOStatement)) {
|
||||||
|
$this->free();
|
||||||
|
}
|
||||||
// 预处理
|
// 预处理
|
||||||
if (empty($this->PDOStatement)) {
|
if (empty($this->PDOStatement)) {
|
||||||
$this->PDOStatement = $this->linkID->prepare($sql);
|
$this->PDOStatement = $this->linkID->prepare($sql);
|
||||||
@@ -386,6 +386,11 @@ abstract class Connection
|
|||||||
return $this->close()->query($sql, $bind, $master, $pdo);
|
return $this->close()->query($sql, $bind, $master, $pdo);
|
||||||
}
|
}
|
||||||
throw new PDOException($e, $this->config, $this->getLastsql());
|
throw new PDOException($e, $this->config, $this->getLastsql());
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
if ($this->isBreak($e)) {
|
||||||
|
return $this->close()->query($sql, $bind, $master, $pdo);
|
||||||
|
}
|
||||||
|
throw $e;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
if ($this->isBreak($e)) {
|
if ($this->isBreak($e)) {
|
||||||
return $this->close()->query($sql, $bind, $master, $pdo);
|
return $this->close()->query($sql, $bind, $master, $pdo);
|
||||||
@@ -416,15 +421,15 @@ abstract class Connection
|
|||||||
$this->bind = $bind;
|
$this->bind = $bind;
|
||||||
}
|
}
|
||||||
|
|
||||||
//释放前次的查询结果
|
|
||||||
if (!empty($this->PDOStatement) && $this->PDOStatement->queryString != $sql) {
|
|
||||||
$this->free();
|
|
||||||
}
|
|
||||||
|
|
||||||
Db::$executeTimes++;
|
Db::$executeTimes++;
|
||||||
try {
|
try {
|
||||||
// 调试开始
|
// 调试开始
|
||||||
$this->debug(true);
|
$this->debug(true);
|
||||||
|
|
||||||
|
//释放前次的查询结果
|
||||||
|
if (!empty($this->PDOStatement) && $this->PDOStatement->queryString != $sql) {
|
||||||
|
$this->free();
|
||||||
|
}
|
||||||
// 预处理
|
// 预处理
|
||||||
if (empty($this->PDOStatement)) {
|
if (empty($this->PDOStatement)) {
|
||||||
$this->PDOStatement = $this->linkID->prepare($sql);
|
$this->PDOStatement = $this->linkID->prepare($sql);
|
||||||
@@ -449,6 +454,11 @@ abstract class Connection
|
|||||||
return $this->close()->execute($sql, $bind);
|
return $this->close()->execute($sql, $bind);
|
||||||
}
|
}
|
||||||
throw new PDOException($e, $this->config, $this->getLastsql());
|
throw new PDOException($e, $this->config, $this->getLastsql());
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
if ($this->isBreak($e)) {
|
||||||
|
return $this->close()->execute($sql, $bind);
|
||||||
|
}
|
||||||
|
throw $e;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
if ($this->isBreak($e)) {
|
if ($this->isBreak($e)) {
|
||||||
return $this->close()->execute($sql, $bind);
|
return $this->close()->execute($sql, $bind);
|
||||||
@@ -652,6 +662,11 @@ abstract class Connection
|
|||||||
return $this->close()->startTrans();
|
return $this->close()->startTrans();
|
||||||
}
|
}
|
||||||
throw $e;
|
throw $e;
|
||||||
|
} catch (\Error $e) {
|
||||||
|
if ($this->isBreak($e)) {
|
||||||
|
return $this->close()->startTrans();
|
||||||
|
}
|
||||||
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user