2

I have a mysql column banneduntil. It's type is "datetime". How would I implement a permanent ban? (I've already implemented a basic ban system with admin/mod defined time). Should I just create a boolean column called "permabanned" and just check if its true or false?

  • 2
    Yes, use a permaban table/column; if someone is permanently banned it makes no sense to waste resources assessing the dates. – David Thomas Dec 22 '12 at 11:46
  • 1
    Just set the banneduntil date to 31-Dec-9999. **If** your system is still running then, they'll be too busy dealing with the y10k problem to worry about a permanently banned member (dead for nearly 10,000 years) trying to get back in. Will the query be: is personX banned now? or is personX not ever supposed to be here? – mcalex Dec 22 '12 at 11:49
  • Please state what table this column `banneduntil` belongs to, so you can get more accurate solutions. – The Nail Dec 22 '12 at 11:57

2 Answers2

5

Provided that banneduntil is in a table called bans:

Set the banneduntil column to NULL. This correctly reflects the meaning of a permanent ban, since it is a ban for an indefinite period.

The Nail
  • 8,355
  • 2
  • 35
  • 48
  • 1
    if banneduntil is null then person is not banned, surely? – mcalex Dec 22 '12 at 11:51
  • 1
    I assume that there is a table for bans, until stated otherwise in the question. If it is just a field in a user table, I would go for the 'for-a-long-long-time' implementation, i.e. setting the value to 31-Dec-9999 as you mentioned. – The Nail Dec 22 '12 at 11:52
  • 1
    +1 Actually, that would be a more correctly normalised structure (which I'm obviously not used to). Still, I bet it's a column in a member table (coz i'm not the only one). – mcalex Dec 22 '12 at 12:37
2

The answer to this depends on what the table contains to denote "not banned"?

Assuming Null/Zero (0000-00-00 00:00:00) then I'd suggest the Maximum DateTime (9999-12-31 23:59:59).

Whilst this offers the risk of another Y2K (Y10K? anyone) I suspect that year 9999 will have bigger issues, assuming your code is still in operation by then.

Andrew
  • 2,046
  • 1
  • 24
  • 37
  • 1
    Worst case scenario is that the banned user rejoins after 9999-12-31. For *most* banned users this is an acceptable scenario :-) – The Nail Dec 22 '12 at 12:00