From ad5c5834eb2d33fc7e87cd9869f49ce8eeb0def7 Mon Sep 17 00:00:00 2001 From: Joyboo Date: Mon, 11 Apr 2022 17:46:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=8B=E5=8A=A1=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Model/BaseModelTrait.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/Model/BaseModelTrait.php b/src/Model/BaseModelTrait.php index bbdd582..a8a600e 100644 --- a/src/Model/BaseModelTrait.php +++ b/src/Model/BaseModelTrait.php @@ -2,6 +2,7 @@ namespace WonderGame\EsUtility\Model; +use EasySwoole\ORM\DbManager; use EasySwoole\RedisPool\RedisPool; use EasySwoole\ORM\AbstractModel; @@ -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() {