From 7dc2a9d9750e107e36a9b74517951551ad13620e Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 3 May 2017 15:37:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BisBreak=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db/Connection.php | 22 +++++++++++++++++++++- library/think/db/connector/Mysql.php | 18 ------------------ 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/library/think/db/Connection.php b/library/think/db/Connection.php index d2aa6ea9..908384cb 100644 --- a/library/think/db/Connection.php +++ b/library/think/db/Connection.php @@ -780,11 +780,31 @@ abstract class Connection /** * 是否断线 * @access protected - * @param \PDOException $e 异常 + * @param \PDOException $e 异常对象 * @return bool */ protected function isBreak($e) { + $info = [ + 'server has gone away', + 'no connection to the server', + 'Lost connection', + 'is dead or not enabled', + 'Error while sending', + 'decryption failed or bad record mac', + 'server closed the connection unexpectedly', + 'SSL connection has been closed unexpectedly', + 'Error writing data to the connection', + 'Resource deadlock avoided', + ]; + + $error = $e->getMessage(); + + foreach ($info as $msg) { + if (false !== stripos($error, $msg)) { + return true; + } + } return false; } diff --git a/library/think/db/connector/Mysql.php b/library/think/db/connector/Mysql.php index 4b6e11a2..dc717532 100644 --- a/library/think/db/connector/Mysql.php +++ b/library/think/db/connector/Mysql.php @@ -130,22 +130,4 @@ class Mysql extends Connection return true; } - /** - * 是否断线 - * @access protected - * @param \PDOException $e 异常对象 - * @return bool - */ - protected function isBreak($e) - { - $info = ['server has gone away', 'Error while sending STMT_']; - $error = $e->getMessage(); - - foreach ($info as $msg) { - if (false !== stripos($error, $msg)) { - return true; - } - } - return false; - } }