I asked this question before and people gave me a solution to my problem but now my problem has changes. Before I had a table called rooms in my database. It had a hold field where when someone is making a reservation, i put a time 15 mins in the future to keep it for that user. The room becomes available again if that user doesn’t finish the reservation in 15 mins. It was the solution to my previous problem.
But now I no longer have a rooms table. I only have roomtype and reservations table. Roomtype got name price info # of rooms and of course id fields. The reservations table got checkin checkout roomtypeid and info about the user. Since I don’t have the rooms table I can’t figure out a way to prevent multiple users from booking a single room at the same time.
My question is how can I prevent race conditions without the rooms table? If it is not too much to ask I would like the solution to be only sql and php.
Here is a link to my previous question
EDIT: I found this post and that’s why I don’t have the rooms table anymore. link
you can add a temporary reservation to the reservations table (with a temp-flag/field) and remove that later if the reservation is not finished after 15 minutes.
additionally if multiple users try to reserve the last room very simultaneously you should again check the availability in every step of the reservation to notify users that the last room has just been taken and propose another roomtype etc.