mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 15:12:48 +08:00
改进断线重连
This commit is contained in:
@@ -361,14 +361,9 @@ abstract class Connection
|
|||||||
// 调试开始
|
// 调试开始
|
||||||
$this->debug(true);
|
$this->debug(true);
|
||||||
|
|
||||||
// 释放前次的查询结果
|
|
||||||
if (!empty($this->PDOStatement)) {
|
|
||||||
$this->free();
|
|
||||||
}
|
|
||||||
// 预处理
|
// 预处理
|
||||||
if (empty($this->PDOStatement)) {
|
$this->PDOStatement = $this->linkID->prepare($sql);
|
||||||
$this->PDOStatement = $this->linkID->prepare($sql);
|
|
||||||
}
|
|
||||||
// 是否为存储过程调用
|
// 是否为存储过程调用
|
||||||
$procedure = in_array(strtolower(substr(trim($sql), 0, 4)), ['call', 'exec']);
|
$procedure = in_array(strtolower(substr(trim($sql), 0, 4)), ['call', 'exec']);
|
||||||
// 参数绑定
|
// 参数绑定
|
||||||
@@ -429,14 +424,9 @@ abstract class Connection
|
|||||||
// 调试开始
|
// 调试开始
|
||||||
$this->debug(true);
|
$this->debug(true);
|
||||||
|
|
||||||
//释放前次的查询结果
|
|
||||||
if (!empty($this->PDOStatement) && $this->PDOStatement->queryString != $sql) {
|
|
||||||
$this->free();
|
|
||||||
}
|
|
||||||
// 预处理
|
// 预处理
|
||||||
if (empty($this->PDOStatement)) {
|
$this->PDOStatement = $this->linkID->prepare($sql);
|
||||||
$this->PDOStatement = $this->linkID->prepare($sql);
|
|
||||||
}
|
|
||||||
// 是否为存储过程调用
|
// 是否为存储过程调用
|
||||||
$procedure = in_array(strtolower(substr(trim($sql), 0, 4)), ['call', 'exec']);
|
$procedure = in_array(strtolower(substr(trim($sql), 0, 4)), ['call', 'exec']);
|
||||||
// 参数绑定
|
// 参数绑定
|
||||||
@@ -659,18 +649,15 @@ abstract class Connection
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (\PDOException $e) {
|
|
||||||
if ($this->isBreak($e)) {
|
|
||||||
return $this->close()->startTrans();
|
|
||||||
}
|
|
||||||
throw $e;
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
if ($this->isBreak($e)) {
|
if ($this->isBreak($e)) {
|
||||||
|
--$this->transTimes;
|
||||||
return $this->close()->startTrans();
|
return $this->close()->startTrans();
|
||||||
}
|
}
|
||||||
throw $e;
|
throw $e;
|
||||||
} catch (\Error $e) {
|
} catch (\Error $e) {
|
||||||
if ($this->isBreak($e)) {
|
if ($this->isBreak($e)) {
|
||||||
|
--$this->transTimes;
|
||||||
return $this->close()->startTrans();
|
return $this->close()->startTrans();
|
||||||
}
|
}
|
||||||
throw $e;
|
throw $e;
|
||||||
@@ -804,6 +791,8 @@ abstract class Connection
|
|||||||
$this->linkWrite = null;
|
$this->linkWrite = null;
|
||||||
$this->linkRead = null;
|
$this->linkRead = null;
|
||||||
$this->links = [];
|
$this->links = [];
|
||||||
|
// 释放查询
|
||||||
|
$this->free();
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user