dpcj40970 2012-05-20 09:11
浏览 11
已采纳

自动更改记录

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?

  • 写回答

4条回答 默认 最新

  • douzhu3654 2012-05-20 09:19
    关注

    I would not use two fields like you did -- because I would not want to depend on a task to change back the active field when the un-ban date is reached.


    Instead, I would only use one datetime field, called like banned_until; and this field would either:

    • Be NULL when the user is not banned,
    • Or contain the date until which the user is banned.

    Then, when the user tries to do something (log-in, post, ...), I would check that :

    • This field is NULL, in which case the user is not banned
    • Or that the date contained in this field is in the past, in which can the user has been banned, but is no longer.

    In the second case, you could even reset the field to NULL, as the un-ban date has been reached.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度