时间:2021-07-01 10:21:17 帮助过:7人阅读
DB::transaction(function () {
DB::table('users')->update(['votes' => 1]);
DB::table('posts')->delete();
});
如何传递参数到匿名函数内呢,如果我这样写,报错
DB::transaction(function ($a, $b, $c) {
DB::table('users')->update(['votes' => 1]);
DB::table('posts')->delete();
});
DB::transaction(function () {
DB::table('users')->update(['votes' => 1]);
DB::table('posts')->delete();
});
如何传递参数到匿名函数内呢,如果我这样写,报错
DB::transaction(function ($a, $b, $c) {
DB::table('users')->update(['votes' => 1]);
DB::table('posts')->delete();
});
DB::transaction(function() use ($a, $b, $c) {
DB::table('users')->update(['votes' => 1]);
DB::table('posts')->delete();
});