From 732b922a4cd4b2422d377dacdd88fe0250aaa584 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Wed, 5 Apr 2023 10:26:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Connection.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Connection.php b/Connection.php index a225b6a..7206701 100644 --- a/Connection.php +++ b/Connection.php @@ -151,11 +151,15 @@ class Connection extends Component /** * @return Mysql\PDO - * @throws ConfigException + * @throws Exception */ public function getMasterClient(): Mysql\PDO { - return $this->connection->get($this->cds); + $client = $this->connection->get($this->cds); + if ($client === false) { + throw new Exception('waite db client timeout.'); + } + return $client; } /** @@ -164,7 +168,11 @@ class Connection extends Component */ public function getSlaveClient(): Mysql\PDO { - return $this->getMasterClient(); + $client = $this->connection->get($this->cds); + if ($client === false) { + throw new Exception('waite db client timeout.'); + } + return $client; } /**