From 1314ccc421ec292e49775d812d795f2aefca7d48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Fri, 17 Jun 2022 15:08:41 +0800 Subject: [PATCH] modify plugin name --- Mysql/PDO.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Mysql/PDO.php b/Mysql/PDO.php index 781a5c7..22170ad 100644 --- a/Mysql/PDO.php +++ b/Mysql/PDO.php @@ -25,8 +25,7 @@ class PDO implements StopHeartbeatCheck private int $_transaction = 0; - - private int $_timer = -1; + private int $_last = 0; public string $dbname; public string $cds; @@ -226,11 +225,16 @@ class PDO implements StopHeartbeatCheck public function check(): bool { try { + if ($this->_last == 0) { + $this->_last = time(); + } + if (time() - $this->_last >= 600) { + throw new Exception('Idle dis.'); + } if (!($this->pdo instanceof \PDO)) { return $result = false; } $this->pdo->getAttribute(\PDO::ATTR_SERVER_INFO); - $result = true; } catch (\Throwable $throwable) { $this->pdo = null;