Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
对于一个旅游网站,我有 4 个人可以一次乘坐出租车。当用户选择座位时,应该为他锁定座位,直到他的会话过期。因为我只是为每个用户更新一个字段“可用性”选择那辆出租车,我不能使用与一行一起使用的 LOCK。如何做到这一点?
使用表格中的同一行来保持预订的座位数。在更新查询之前获取行上的锁。这样您就可以强制第二个用户等待锁定,直到第一个用户更新座位数。