商品管理需求分析
1、实现商品无限级分类管理【类似京东三级分类】
2、添加商品时要指定商品属于一个主分类和多个扩展分类【扩展分类可以是其他主分类】
3、商品列表中可以根据分类搜索商品
a) 搜索一个分类小的商品时,这个分类所有子分类下的商品也应该被搜索出来
b) 搜索时要考虑商品的主分类和扩展分类
无限级的商品分类
思路:递归打印树形结构;递归查找分类所有子分类【以便删除时使用】
1、建表
drop table if exists p39_category; create table p39_category( id mediumint unsigned not null auto_increment comment 'Id', cat_name varchar(30) not null comment '分类名称', parent_id mediumint unsigned not null default '0' comment '上级分类id,0:顶级分类', primary key(id) )engine=InnoDB default charset=utf8 comment '分类';