From eb36a30b26ae5619ee9d25091d7ab2d9133d53cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Wed, 8 Jun 2022 15:13:53 +0800 Subject: [PATCH] modify plugin name --- Command.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Command.php b/Command.php index 5310dc8..6a76135 100644 --- a/Command.php +++ b/Command.php @@ -137,15 +137,13 @@ class Command extends Component */ private function _execute(): bool|int { + $pdo = $this->db->masterInstance(); try { - $pdo = $this->db->masterInstance(); - $result = $pdo->execute($this->sql, $this->params); - - $this->db->release($pdo, true); } catch (\Throwable $exception) { $result = $this->logger->addError($this->sql . '. error: ' . $exception->getMessage(), 'mysql'); } finally { + $this->db->release($pdo, true); return $result; } } @@ -158,15 +156,13 @@ class Command extends Component */ private function search(string $type): array|int|bool|null { + $pdo = $this->db->slaveInstance(); try { - $pdo = $this->db->slaveInstance(); - $data = $pdo->{$type}($this->sql, $this->params); - - $this->db->release($pdo, false); } catch (\Throwable $throwable) { $data = $this->logger->addError($this->sql . '. error: ' . $throwable->getMessage(), 'mysql'); } finally { + $this->db->release($pdo, false); return $data; } }