-- 表的结构 `coverage`
--
CREATE TABLE IF NOT EXISTS `coverage` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`pid` int(10) unsigned DEFAULT NULL,
`coverageName` varchar(100) DEFAULT NULL,
`coverageDesc` varchar(200) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `pid` (`pid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=20 ;
--
-- 转存表中的数据 `coverage`
--
INSERT INTO `coverage` (`id`, `pid`, `coverageName`, `coverageDesc`) VALUES
(16, NULL,'类别',''),
(17, 16,'类别一',''),
(18, NULL,'分类',''),
(19, 17,'类别二','');
--
-- 限制表 `coverage`
--
ALTER TABLE `coverage`
ADD CONSTRAINT `coverage_ibfk_1` FOREIGN KEY (`pid`) REFERENCES `coverage` (`id`) ONDELETECASCADE;
然后才Controller中添加下面的代码:
done!