From ccacfcbc0206dd4de138ff9f06a3c177f70aba4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Thu, 17 Aug 2023 10:16:08 +0800 Subject: [PATCH] qqq --- Command.php | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/Command.php b/Command.php index 38ce975..71cc990 100644 --- a/Command.php +++ b/Command.php @@ -13,11 +13,8 @@ namespace Database; use Exception; use Kiri\Abstracts\Component; use Kiri\Di\Container; -use Kiri\Di\Context; use Kiri\Exception\ConfigException; use PDO; -use PDOStatement; -use ReflectionException; use Throwable; /** @@ -89,7 +86,7 @@ class Command extends Component return $prepare->fetchAll(PDO::FETCH_ASSOC); } catch (Throwable $throwable) { $result = $this->error($throwable); - if (str_contains($throwable->getMessage(), 'MySQL server has gone away') && $this->retry()) { + if (str_contains($throwable->getMessage(), 'MySQL server has gone away')) { return $this->all(); } return $result; @@ -113,7 +110,7 @@ class Command extends Component return $prepare->fetch(PDO::FETCH_ASSOC); } catch (Throwable $throwable) { $result = $this->error($throwable); - if (str_contains($throwable->getMessage(), 'MySQL server has gone away') && $this->retry()) { + if (str_contains($throwable->getMessage(), 'MySQL server has gone away')) { return $this->one(); } return $result; @@ -137,7 +134,7 @@ class Command extends Component return $prepare->fetchColumn(PDO::FETCH_ASSOC); } catch (Throwable $throwable) { $result = $this->error($throwable); - if (str_contains($throwable->getMessage(), 'MySQL server has gone away') && $this->retry()) { + if (str_contains($throwable->getMessage(), 'MySQL server has gone away')) { return $this->fetchColumn(); } return $result; @@ -161,7 +158,7 @@ class Command extends Component return $prepare->rowCount(); } catch (Throwable $throwable) { $result = $this->error($throwable); - if (str_contains($throwable->getMessage(), 'MySQL server has gone away') && $this->retry()) { + if (str_contains($throwable->getMessage(), 'MySQL server has gone away')) { return $this->rowCount(); } return $result; @@ -171,19 +168,6 @@ class Command extends Component } - /** - * @return bool - */ - protected function retry(): bool - { - if (Context::increment(self::RETRY_NAME) < 3) { - return true; - } - Context::remove(self::RETRY_NAME); - return false; - } - - /** * @return int|bool * @throws Exception @@ -215,7 +199,7 @@ class Command extends Component return $result == 0 ? true : (int)$result; } catch (Throwable $throwable) { $result = $this->error($throwable); - if (str_contains($throwable->getMessage(), 'MySQL server has gone away') && $this->retry()) { + if (str_contains($throwable->getMessage(), 'MySQL server has gone away')) { return $this->_execute(); } return $result;