Reputation: 367
For example I made a reservation for a restaurant and it expires in 24 hours. In the reservation table of the db (MySQL), how do I automatically update the status to expired after 24 hours? What approach would you guys suggest? Thanks in advance!
Upvotes: 0
Views: 2481
Reputation: 1959
I would suggest the following two methods.
Upvotes: 0
Reputation: 1
using cron can be liitle difficult
just run update query by comparing timestamp value with your time limit.
it will work.
Upvotes: 0
Reputation: 2406
Use cron like Unreason said or MySQL events, see Create event.
Upvotes: 1
Reputation: 1237
Don't really know the problem you're trying to handle but I'd store the timestamp when the reservation was made and have a field which stores after what interval from the point reservation was made does it expire (24 hrs in your case) and that's it. The rest should be handled at the point where you read/display that information.
Besides if you still really want to CHANGE the value in DB go for a cron that regularly updates the DB
Upvotes: 7
Reputation: 12704
Running periodical tasks is usually done with cron.
Here are some instructions how to use it on drupal (which is php/mysql)
Upvotes: 1