2016-12-16 45 views
1

我有一個用戶表與用戶的詳細信息和朋友表與用戶名(FK),friendid和狀態(枚舉 - >發送,接受,塊)現在我需要搜索朋友通過輸入朋友的名字和之後我需要發送請求好友併發送請求給朋友後,當他登錄到他的賬戶必須有對朋友的要求通知......如何使用yii2在php中關聯用戶表和朋友表時發送好友請求?

+0

該進程的哪一部分是你問的?另外,不要使用枚舉。 – Slytherin

回答

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 
0

我有相同的數據庫設計,我創建了一個表名「通知」與以下字段。

  1. Noification_Id(INT AI)
  2. SENDER_ID(INT)
  3. Receiver_ID(INT)
  4. 消息(字符串)
  5. READ_STATUS(INT)
  6. 狀態

一旦你會發送請求它會插入通知到這張表,然後當其他用戶登錄時你需要fe tch通知使用receiver_id和read_status檢查user_id。一旦用戶接受好友請求,您需要更新通知表以及好友表。

相關問題