From 5c183173ad69b8bc6d35e221139513c870914a40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E5=BD=AA?= Date: Fri, 29 May 2020 11:48:24 +0800 Subject: [PATCH] check pdo connection alive --- src/Connectors/PDOConnector.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Connectors/PDOConnector.php b/src/Connectors/PDOConnector.php index 73762b9..396edae 100644 --- a/src/Connectors/PDOConnector.php +++ b/src/Connectors/PDOConnector.php @@ -23,7 +23,11 @@ public function disconnect($connection) public function isConnected($connection): bool { /**@var \PDO $connection */ - return !!$connection->getAttribute(\PDO::ATTR_SERVER_INFO); + try { + return !!$connection->getAttribute(\PDO::ATTR_SERVER_INFO); + } catch (\Throwable $e) { + return false; + } } public function reset($connection, array $config)