transaction - laravel transaction does not commit. I don't know where I wrote it wrong.
PHP中文网
PHP中文网 2017-05-16 16:49:04
0
2
393

laravel transaction is not committed. I don’t know where I wrote it wrong

The following is the code
DB::transaction(function () use ($payment,$userBalance) {

            Payment::insert($payment);
            $userName = $payment['payment_user_name'];
            User::where('user_name', $userName)
                 ->increment('user_balance', $userBalance);
        });
        
        
        跪求指教
PHP中文网
PHP中文网

认证0级讲师

reply all(2)
小葫芦
DB::transaction(function () use ($payment,$userBalance) {
         try {
            Payment::insert($payment);
            $userName = $payment['payment_user_name'];
            User::where('user_name', $userName)->increment('user_balance', $userBalance);
         } catch (\Exception $e) {
            var_dump($e);
            exit;
         }
});
刘奇
//打印输出下sql 看是否有问题,因为在 transaction 闭包若抛出任何异常会导致事务自动回滚
\DB::listen(function ($sql,$bind) { 
   dump($sql,$bind);
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!