Skip to content

Commit

Permalink
增加事务相关操作
Browse files Browse the repository at this point in the history
  • Loading branch information
Joyboo committed Apr 11, 2022
1 parent a8072b7 commit ad5c583
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/Model/BaseModelTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace WonderGame\EsUtility\Model;

use EasySwoole\ORM\DbManager;
use EasySwoole\RedisPool\RedisPool;
use EasySwoole\ORM\AbstractModel;

Expand Down Expand Up @@ -416,6 +417,23 @@ protected function _after_delete($res)
$where = [];
}

// 开启事务
public function startTrans()
{
DbManager::getInstance()->startTransaction($this->getQueryConnection());
}

public function commit()
{
DbManager::getInstance()->commit($this->getQueryConnection());

}

public function rollback()
{
DbManager::getInstance()->rollback($this->getQueryConnection());
}

/******************** 兼容部分项目 _error ,最好能改为异常处理 ************************/
public function getError()
{
Expand Down

0 comments on commit ad5c583

Please sign in to comment.