From a92c9804e585ad1ffd62e8cd3e735614f1c61da0 Mon Sep 17 00:00:00 2001 From: zxin <14545600+NHZEX@users.noreply.github.com> Date: Wed, 7 Jun 2023 13:22:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=A4=E6=96=AD=E4=BA=8B?= =?UTF-8?q?=E5=8A=A1=E6=97=B6Db=E5=AE=9E=E4=BE=8B=E9=94=99=E8=AF=AF=20(#53?= =?UTF-8?q?2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Conflicts: # src/Db/Query/Query.php --- src/Db/Query/Query.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Db/Query/Query.php b/src/Db/Query/Query.php index 949939842c..1c9e16078a 100644 --- a/src/Db/Query/Query.php +++ b/src/Db/Query/Query.php @@ -146,6 +146,11 @@ public function setOption($option): self */ public function getDb(): IDb { + if (!$this->isInitDb) + { + $this->db = Db::getInstance($this->poolName, $this->queryType); + } + return $this->db; } @@ -892,7 +897,12 @@ public function setFieldDec(string $fieldName, float $decValue = 1): self */ protected function isInTransaction(): bool { - return QueryType::WRITE === $this->queryType && Db::getInstance($this->poolName)->inTransaction(); + if (QueryType::WRITE !== $this->queryType) + { + return false; + } + + return $this->getDb()->inTransaction(); } /**