我有三张桌子:
CREATE TABLE `user` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(160) DEFAULT NULL,
PRIMARY KEY (`id`)
)
CREATE TABLE `event` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`title` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`)
)
CREATE TABLE `user_join_event` (
`user_id` int(10) unsigned NOT NULL,
`event_id` int(10) unsigned NOT NULL,
`created` datetime NOT NULL,
PRIMARY KEY (`user_id`,`event_id`),
CONSTRAINT `user_join_event_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`),
CONSTRAINT `user_join_event_ibfk_2` FOREIGN KEY (`event_id`) REFERENCES `event` (`id`)
)
User
Event
与by有关系UserJoinEvent
:
'events' => array(self::MANY_MANY, 'Event', 'user_join_event(user_id, event_id)'),
我想created
在user_join_event
餐桌上抽时间