【问题标题】:how to a send friend request while the user table and the friends table are in relation in php using yii2?当用户表和好友表在使用 yii2 的 php 中相关时,如何发送好友请求?
【发布时间】:2016-12-16 13:28:10
【问题描述】:

我有一个包含用户详细信息的用户表和一个包含用户 ID(FK)、朋友 ID 和状态(枚举->发送、接受、块)的朋友表,现在我需要通过输入朋友姓名和之后我需要向那个朋友发送请求,并且在他登录到他的帐户时向他发送请求后,必须有一个关于朋友请求的通知......

【问题讨论】:

  • 您要询问的是该过程的哪一部分?另外,不要使用枚举。

标签: php yii2


【解决方案1】:

我还有另一个数据库设计主张:

Table: FriendRequest 
Fields: frID->Id 
        frSendBy->Id of the sender (in relation with User Table) 
        frSendTo -> Id of the receiver (in relation with User Table) 
        frIsViewed -> 1 or 0 if the request is viewed or not 
        frAccepted -> 1 or 0 if the request is accepted or refused

【讨论】:

    【解决方案2】:

    我有相同的数据库设计,我创建了一个包含以下字段的表名“通知”。

    1. Noification_Id (int AI)
    2. Sender_ID (int)
    3. Receiver_ID (int)
    4. 消息(字符串)
    5. read_status(int)
    6. 状态

    一旦您发送请求,它将向该表插入通知,然后当其他用户登录时,您需要获取通知检查 user_id 与接收者 ID 和读取状态。用户接受好友请求后,您需要更新通知表和好友表。

    【讨论】:

      猜你喜欢
      • 2017-05-18
      • 2014-04-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-13
      相关资源
      最近更新 更多