src/Leevel/Database/Connect.php
public function transaction(Closure $action)
    {
        $this->beginTransaction();

        try {
            $result = call_user_func_array($action, [
                $this,
            ]);

            $this->commit();

            return $result;
        } catch (Throwable $e) {
            $this->rollBack();

            throw $e;
        }
    }
public function transaction(Closure $action)
    {
        $this->beginTransaction();

        try {
            $result = call_user_func_array($action, [
                $this,
            ]);

            $this->commit();

            return $result;
        } catch (Throwable $e) {
            $this->rollBack();

            throw $e;
        }
    }
执行数据库事务

@param \Closure $action

@return mixed