Skip to content

Commit

Permalink
修复判断事务时Db实例错误 (#532)
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/Db/Query/Query.php
  • Loading branch information
NHZEX authored and Yurunsoft committed Jun 9, 2023
1 parent e1e1899 commit a92c980
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Db/Query/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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();
}

/**
Expand Down

0 comments on commit a92c980

Please sign in to comment.