On the website i’m developing i’m making a system for ban and unban users.
In my database i have a table ‘banned’ with fields about the bans (userID, active, date was made, reason ecc).
What i want to do is:
Add another field for expire date, and when this date occur, change automatically the field ‘active’ to 0.
How i can do that?
I would not use two fields like you did — because I would not want to depend on a task to change back the
activefield when the un-ban date is reached.Instead, I would only use one datetime field, called like
banned_until; and this field would either:NULLwhen the user is not banned,Then, when the user tries to do something (log-in, post, …), I would check that :
NULL, in which case the user is not bannedIn the second case, you could even reset the field to
NULL, as the un-ban date has been reached.