管理用户警告 [英] Manage user warnings
问题描述
我不习惯使用每次间隔都会递减的值,例如警告用户,例如,对30 days
持续存在的警告,在用户被禁止之前可以达到3 warns
的最大值
I'm not used to work with values that should decrement every a timelapse like for a user warned, for example a warn which persist for 30 days
that can reach a maximum value of 3 warns
before the user get banned
我曾想设计一个这样的用户表,但是现在我应该对其进行处理,我发现它对于每30天减少一次值没有用:
I thought to design a user table like this but now I should work on it, I find it not useful on decrementing the values every 30 days:
table_user
- username
- email
- warnings (integer)
- last_warn (timestamp data type)
我应该使用一些php计时器吗?
should I use some php timer?
关于用户警告是否存在任何标准技术?
does exist any standard tecnique on user warnings?
推荐答案
通过打破用户的警告来规范化表,例如:
Normalize your tables, by breaking out the warnings from the user, like:
Table: Users
UserID int auto generate PK
UserName
UserEmail
Table: UserWarnings
UserID
WarningDate
您现在可以编写查询以确定在过去30天内是否有三个警告.发生警告"时运行此查询,如果返回一行,则禁止该用户.
you can now write a query to determine if there are three warning in the last 30 days. Run this query when a "warn" happens, and if a row is returned, ban the user.
查询看起来像这样:
SELECT
COUNT(*)
FROM UserWarnings
WHERE UserID=...your user id... AND WarningDate>=...current date time...
HAVING COUNT(*)>2
通过制作警告表,您可以保留完整的警告历史记录,这可能很有用.
By making a warning table, you can keep a complete warning history, which may be useful.
这篇关于管理用户警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!