【发布时间】:2016-04-10 18:54:22
【问题描述】:
假设我有一张桌子
CREATE TABLE IF NOT EXISTS `Message` (
`ConMsgID` int(11) NOT NULL AUTO_INCREMENT,
`SenderID` int(11) DEFAULT NULL,
`ReceiverID` int(11) DEFAULT NULL,
`Text` text NOT NULL,
`DateTime` datetime NOT NULL,
`ReadStatus` tinyint(1) NOT NULL,
`ReadDateTime` datetime DEFAULT NULL,
PRIMARY KEY (`ConMsgID`),
KEY `UserID` (`SenderID`),
KEY `ReceiverID` (`ReceiverID`)
)
这是一个聊天消息表。想象一下 2 个用户正在互相聊天。 USER1 和 USER2
案例 1:
USER1 向 USER2 发送了 20 条消息,并且 USER2 未读取和。当 USER2 打开对话时,他必须看到所有 20 条消息。
案例 2:
USER2 回复 USER1 并发送 3 条消息,但未被 USER1 阅读。当 USER1 打开对话时,他将看到两个用户的最后 15 条消息。
希望我现在清楚
【问题讨论】:
标签: php sql codeigniter codeigniter-3