我想让用户互相发送消息,现在这是当前模式
CREATE TABLE IF NOT EXISTS `inbox` (
`id` int(11) NOT NULL auto_increment,
`id_usuario` int(11) NOT NULL,
`id_to` int(11) NOT NULL,
`mensaje` varchar(250) collate utf8_spanish_ci NOT NULL,
`texto` text collate utf8_spanish_ci NOT NULL,
`fecha` date NOT NULL,
`visto` int(1) NOT NULL,
`adjunto` int(1) NOT NULL,
`item` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci AUTO_INCREMENT=1 ;
对于这个问题,我认为它只是相关的:
- id_usuario - 来自用户(发件人)的唯一 ID
- id_to - 来自用户(接收者)的唯一 ID
- id - 唯一的消息 ID
我在想,
如果我将“id_to”类型从整数(只有一个 ID)更改为 varchar,以便:
id_usuario - 与用户(接收者)分隔的多个唯一 ID 的逗号
并存储多个接收者,例如(多个 ID):'333、444、555'
我能够:
- 向每个接收者显示消息?
仍在弄清楚查询,它会是这样的:
"select * from inbox where sesionid IN (idto)"
??
- 向发件人显示邮件的每个收件人?仍在弄清楚查询,会不会像
"select id_to from inbox where id = '254'"
然后由','爆炸?
或者,
我应该改变我的计划吗?