Skip to content

Commit

Permalink
还原Query类的事务方法
Browse files Browse the repository at this point in the history
  • Loading branch information
liu21st committed Jun 22, 2020
1 parent 0d4b9d0 commit 35ca511
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/db/concern/Transaction.php
Expand Up @@ -71,4 +71,47 @@ public function transactionXa($callback, array $dbs = [])
}
}

/**
* 执行数据库事务
* @access public
* @param callable $callback 数据操作方法回调
* @return mixed
*/
public function transaction(callable $callback)
{
return $this->connection->transaction($callback);
}

/**
* 启动事务
* @access public
* @return void
*/
public function startTrans(): void
{
$this->connection->startTrans();
}

/**
* 用于非自动提交状态下面的查询提交
* @access public
* @return void
* @throws PDOException
*/
public function commit(): void
{
$this->connection->commit();
}

/**
* 事务回滚
* @access public
* @return void
* @throws PDOException
*/
public function rollback(): void
{
$this->connection->rollback();
}

}

0 comments on commit 35ca511

Please sign in to comment.