1

I have been developing ban system with temporary banning system and I'm looking if there's anyway to update a row to specific value using a timer within MySQL. For instance,

I need my field banned to be set to 0 where the rowid is X.

UPDATE mytable SET banned=0 WHERE rowid=X

- But this query has to be done within X minutes or seconds specified, like if we could delay it.

  • Banning a user temporarily for 60 seconds, query sent at that time:

"UPDATE mytable SET banned=1, unbanon=NOW()+60 WHERE rowid=X".

Could I possibly get MySQL to automatically set banned variable to 0 after 60 seconds has passed?

Thank you.

MrYo
  • 1,797
  • 3
  • 19
  • 33

1 Answers1

0

Set a cron job to run a query every minute that will do something like :

UPDATE mytable SET banned=0 WHERE unbanon <= NOW() AND banned=1
Fabien TheSolution
  • 5,055
  • 1
  • 18
  • 30