未验证 提交 80d1c6f2 编写于 作者: Z zxin 提交者: GitHub

修复判断事务时Db实例错误 (#532)

上级 47a81308
......@@ -184,6 +184,11 @@ abstract class Query implements IQuery
*/
public function getDb(): IDb
{
if (!$this->isInitDb)
{
$this->db = Db::getInstance($this->poolName, $this->queryType);
}
return $this->db;
}
......@@ -886,15 +891,7 @@ abstract class Query implements IQuery
{
try
{
$db = &$this->db;
if (!$this->isInitDb)
{
$db = Db::getInstance($this->poolName, $this->queryType);
}
if (!$db)
{
return new $resultClass(false);
}
$db = $this->getDb();
$stmt = $db->prepare($sql);
$binds = $this->binds;
$this->binds = [];
......@@ -971,7 +968,12 @@ abstract class Query implements IQuery
*/
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();
}
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册