duanfei9278 2012-03-18 19:54
浏览 230
已采纳

将MySQL数据标记为“已读”

I am working on a notification system on my website for users. I have a table for "events" that a user is notified of when they happen (friend requests, new followers, comments, etc.). Is there a way to insert a value like say 0 for unread and 1 for read in the //read column of the events table, for a particular event (upon request of the information by the user)? So that it is no longer notification worthy?

  • 写回答

2条回答 默认 最新

  • dswmmvrg40957 2012-03-18 19:58
    关注

    Yep. Just store your column as TINYINT(1). The MySQL literal TRUE evaluates to 1 and FALSE evaluates to 0, as expected.

    (This is assuming your events table stores the individual events that get assigned to users, not the general event types that can occur.)

    Usage

    SELECT * FROM events WHERE user_id = [user_id] AND read = 0    #list all for user
    UPDATE events SET read = 1 WHERE event_id = [event_id]         #mark as read
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败