View Single Post
Old 12-03-2012, 09:58 PM   PM User | #2
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
If it were me, I'd add a column to your table alongside your status called status_changed. This would store a timestamp that gets updated to current datetime any time the status changes.

Then the tricky part comes in what mechanism do you use to check that timestamp and take action when 20 minutes is up? Well you can't count on the client at all. He could simply turn off his PC, you'd never know (unless you had Ajax pinging you back, which is usually not a good solution).

So, how about a CRON job that runs every minute? It would do just the one task: query the entire database table looking for rows with a "reserved" status and a status_changed timestamp older than 20 minutes. If it finds anything, update the status back to available and maybe send an email to the buyer that he missed his chance at buying the item.
__________________
Fumigator is offline   Reply With Quote