|
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.
|