Temporary reservation

1

I have the following problem:

I'm creating a booking application and once a user clicks on a product to book, that product must be removed from the list of those temporarily available to complete the reservation. If it does not finish in 5 minutes, this product is back in stock.

I was able to make this reservation by doing an update in the status column of the product, but I have no idea how to make it return to availability after 5 minutes.

Can anyone help me?

    
asked by anonymous 14.05.2018 / 17:24

1 answer

0

You can use EVENT of MySQL , so you first need to enable the feature in your database:

SET GLOBAL event_scheduler = ON;

Create the event:

CREATE EVENT mudar_status
ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 5 MINUTE
DO
UPDATE tabela_status
SET status = 1
WHERE status = 0
    
16.05.2018 / 13:19