This commit is contained in:
2023-04-03 17:30:07 +08:00
parent 4e109ffdf8
commit 92ab70d59d
+6 -5
View File
@@ -232,10 +232,10 @@ class PDO implements StopHeartbeatCheck
private function queryPrev(string $sql, array $params = []): PDOStatement private function queryPrev(string $sql, array $params = []): PDOStatement
{ {
try { try {
if ($this->_timerId === -1) { // if ($this->_timerId === -1) {
$this->_timerId = Timer::tick(6000, [$this, 'check']); // $this->_timerId = Timer::tick(6000, [$this, 'check']);
} // }
$this->_last = time(); // $this->_last = time();
if (($statement = $this->_pdo()->query($sql)) === false) { if (($statement = $this->_pdo()->query($sql)) === false) {
throw new Exception($this->_pdo()->errorInfo()[1]); throw new Exception($this->_pdo()->errorInfo()[1]);
} }
@@ -256,6 +256,7 @@ class PDO implements StopHeartbeatCheck
*/ */
public function check(): bool public function check(): bool
{ {
return true;
try { try {
if ($this->_last == 0) $this->_last = time(); if ($this->_last == 0) $this->_last = time();
if (time() - $this->_last >= 600) { if (time() - $this->_last >= 600) {
@@ -263,7 +264,7 @@ class PDO implements StopHeartbeatCheck
} else if (!($this->pdo instanceof \PDO)) { } else if (!($this->pdo instanceof \PDO)) {
return $result = false; return $result = false;
} }
$this->pdo->getAttribute(\PDO::ATTR_SERVER_INFO); $this->_pdo()->getAttribute(\PDO::ATTR_SERVER_INFO);
$result = true; $result = true;
} catch (\Throwable $throwable) { } catch (\Throwable $throwable) {
if (!str_contains($throwable->getMessage(), 'Idle dis')) { if (!str_contains($throwable->getMessage(), 'Idle dis')) {