事务中对一条数据锁定两次会怎么样?
<?php
$id = 1;
DB::transaction(function () use ($id) {
//锁定数据
Cart::where('id', $id)->lockForUpdate()->first();
# 逻辑代码
Cart::where('id', $id)->lockForUpdate()->first();
});
这样会出现BUG吗?按我的理解这样不会出问题吧,为了保险起见,先咨询一下大佬们
推荐文章: