for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// | Copyright (c) 2006~2019 http://thinkphp.cn All rights reserved.
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// | Author: liu21st <[email protected]>
declare (strict_types = 1);
namespace think\db\concern;
/**
* 事务支持
*/
trait Transaction
{
* 执行数据库事务
* @access public
* @param callable $callback 数据操作方法回调
* @return mixed
public function transaction(callable $callback)
return $this->connection->transaction($callback);
}
* 启动事务
* @return void
public function startTrans(): void
$this->connection->startTrans();
* 用于非自动提交状态下面的查询提交
* @throws PDOException
public function commit(): void
$this->connection->commit();
* 事务回滚
public function rollback(): void
$this->connection->rollback();