当拿到项目后首先应该根据页面初始化数据与SQL数据库中的查询数据进行比对,进行初始化界面测试
初始化页面数据加载分析
1.查询首页的顶级分类
select * from iwebshop_category where parent_id=0 and visibility=1 order by sort
查询二级分类商品:如“服饰鞋帽”的下级分类
select * from iwebshop_category
where parent_id=57 and visibility=1
orderby sort
练习:参考以上sql查看其它二级分类
2.搜索关键字(可以在后台商品—>关键字列表中设置)
select * from iwebshop_keyword where hot=1 order by order
asc limit 5
3.Shop资讯
select * from iwebshop_article where visiblity=1 and top=1 order by create_time desclimit 5
练习:在后台工具–公告列表中添加几条公告,并到公告消息表中查看对应的数据表,编写SQL查询最新的5条公告,查看是否一致
答案:
select * from iwebshop_announcement order by id desc limit 5;
或者
select * from iwebshop_announcement order by time desc limit 5
4.右下方关键词列表–与搜索关键字一致,取数据条数为8条
select * from iwebshop_keyword where hot=1 order by order
asc limit 8
5.最新商品列表:(商品推荐类型可以在后台商品–商品列表中设置)
在此查询中涉及到两张表分别是iwebshop_good商品信息表和iwebshop_commend_goods推荐类商品表,并通过商品id建立两张表之间的关系,条件为最新商品,并按照上架日期进行降序排序,查询数量为8条
select g.id,
g.name,
g.sell_price,
g.market_price,
g.list_img
from iwebshop_commend_goods as co
inner join iwebshop_goods as g on g.id=co.goods_id
where co.commend_id=1
order by g.up_time desc
limit 8
通过以上可知最新商品、特价商品、热卖商品、推荐商品记录保存在iwebshop