laravel5.5mysql事务报错 Type error: Too few arguments to function

DB::transaction(function () {
    DB::table('users')->update(['votes' => 1]);
    DB::table('posts')->delete();
});

上面这是laravel5.5官方的方法,但是我不知道为什么我这边会不断报错。

后来我就直接改了另外一种事务手动回滚。

  DB::beginTransaction($payinfo,$paycpinfo);
        try {
            $pay1 = Pay::create($payinfo);
            $pay2 = PayCpinfo::create($paycpinfo);
            if($pay1&&$pay2){
                DB::commit();
                $data=array();
                $data['pay']['productname']=$payinfo['productname'];
                $data['pay']['amount']=$payinfo['amount'];
                $data['pay']['agent_id']=$payinfo['agent_id'];
                $data['pay']['orderid']=$payinfo['orderid'];
                $model2=PayWay::where('status',1)->get();
                $data['payway']=$model2->toArray();
                return view('rrrr')->with('data', $data);;
            }
        } catch (\Exception $e) {
            DB::rollBack();
            return response(['code' => 'fail','status'=>false,'msg'=>"系统错误"]);
        }

你可能感兴趣的:(PHP,mysql,php,mysql,laravel,事务)