Laravel 5.0 Documentation
commands! For example, a command pipe could wrap the entire command operation within a database transaction, or simply log its execution. To add a pipe to your bus, call the pipeThrough method of the UseDatabaseTransactions { public function handle($command, $next) { return DB::transaction(function() use ($command, $next) { return $next($command); Queued Commands Closure as a command pipe: $dispatcher->pipeThrough([function($command, $next) { return DB::transaction(function() use ($command, $next) { return $next($command); } }]); Managers & Factories0 码力 | 242 页 | 1.44 MB | 1 年前3
Laravel 5.1 中文文档} } 3、数据库事务 想要在一个数据库事务中运行一连串操作,可以使用 DB 门面的 transaction 方法,如果事 务闭包中抛出异常,事务将会自动回滚。如果闭包执行成功,事务将会自动提交。使用 transaction 方法时不需要担心手动回滚或提交: DB::transaction(function () { DB::table('users')->update(['votes'0 码力 | 307 页 | 3.46 MB | 1 年前3
Laravel 5.6 中文文档} } 数据库事务 想要在一个数据库事务中运行一连串操作,可以使用 DB 门面的 transaction 方法,使用 transaction 方法时不需要手动回滚或提交:如果事务闭 包中抛出异常,事务将会自动回滚;如果闭包执行成功,事务将会自动提交: DB::transaction(function () { DB::table('users')->update(['votes' 要等待另一方退出才能获取资源,但是没有一方提前退出,就会造成死锁,数据库 事务容易造成的一个副作用就是死锁。为此 transaction 方法接收一个可选参数作为第二个参数,用于定义死锁发生时事务的最大重试次数。如果 尝试次数超出指定值,会抛出异常: DB::transaction(function () { DB::table('users')->update(['votes' =>0 码力 | 377 页 | 14.56 MB | 1 年前3
Laravel 5.2 中文文档87 3、数据库事务 想要在一个数据库事务中运行一连串操作,可以使用 DB 门面的 transaction 方法,如果事 务闭包中抛出异常,事务将会自动回滚。如果闭包执行成功,事务将会自动提交。使用 transaction 方法时不需要担心手动回滚或提交: DB::transaction(function () { DB::table('users')->update(['votes'0 码力 | 377 页 | 4.56 MB | 1 年前3
Laravel 6.0 中文文档anjun.com 949 想要在一个数据库事务中运行一连串操作,可以使用 DB 门面 的 transaction 方法,使用 transaction 方法时不需要手动回滚或 提交:如果事务闭包中抛出异常,事务将会自动回滚;如果闭包执行 成功,事务将会自动提交: DB::transaction(function () { DB::table('users')->update(['votes' 等待另一方退出才能获取资源,但是没有一方提前退出,就会造成死 锁,数据库事务容易造成的一个副作用就是死锁。为 此 transaction 方法接收一个可选参数作为第二个参数,用于定义 死锁发生时事务的最大重试次数。如果尝试次数超出指定值,会抛出 异常: DB::transaction(function () { DB::table('users')->update(['votes' => 1]);0 码力 | 1442 页 | 14.66 MB | 1 年前3
Laravel 5.3 中文文档414 3、数据库事务 想要在一个数据库事务中运行一连串操作,可以使用 DB 门面的 transaction 方法,如果事务闭 包中抛出异常,事务将会自动回滚。如果闭包执行成功,事务将会自动提交。使用 transaction 方法时不需要担心手动回滚或提交: DB::transaction(function () { DB::table('users')->update(['votes'0 码力 | 691 页 | 9.37 MB | 1 年前3
共 6 条
- 1













