Answer the question
In order to leave comments, you need to log in
How to make a value in the database change after a certain time?
The task is that it is necessary to change the data of the MySQL table (id_status ) after a certain time. For example, a client makes a reservation at 14:00. The status of the place is "Booked" (id_status = 1). If during the day he did not pay for the order, then change the value of id_status = 0. How can I implement this using (PHP, MYSQL)?
Answer the question
In order to leave comments, you need to log in
If during the day he did not pay for the order, then change the value of id_status = 0.
Either cron and a command that checks whether a day has passed since the booking and changes the status.
Or, somewhere in the model, make the isBooked method that will return true if the status is 'booked' and the day has not yet passed, and false otherwise. But most likely it will be necessary to add logic somewhere that will change the status in the database if this method returns false (as in the answer above, you can write this logic into a trigger, they are in mysql).
Without examples, it is difficult to advise something more detailed.
MySQL has a built-in scheduler or events. You can create a one-time event for each such event with the removal of the necessary one, or make a single event that will do the same for the entire database at certain intervals.
You need a handler running in the background.
Under certain conditions, it will perform certain actions.
Usually a console application is made that uses the console kernel, but your classes, configs, etc. are the same.
You can run such an application by cron every minute, or you can make it a daemon.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question