tags:

views:

56

answers:

4

Hi,

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!

+1  A: 

Running periodical tasks is usually done with cron.

Here are some instructions how to use it on drupal (which is php/mysql)

Unreason
+7  A: 

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

Gunjan
+1 the first paragraph **is** the way to do it. Wanting to actually change the value is probably a flawed idea in the first place. There may be exceptions but they are, after all, only exceptions.
Lo'oris
+1  A: 

Use cron like Unreason said or MySQL events, see Create event.

Piotr Pankowski
+2  A: 

Hello, I would suggest the following two methoads.

  1. To run a cookie at the background and check it out if the time(here in this case 24hrs) ran out or not..
  2. Store the entry in the database with datetime. As we check whether the user logged in or not with session variables. In the similar way for everyclick in the site, call a function to check whether the time is lapsed or not.
lucky