// 栏目首页 列表 public function index() { // 顶级栏目排序 $topid = db('arctype')->where('topid',0)->field('id')->order('id asc')->select(); // 定义空数组 $typeid = array(); foreach ($topid as $key => $value) { $munuid = db('arctype')->where('topid',$value['id'])->field('id')->order('id asc')->select(); $typeid[].= $value['id']; foreach ($munuid as $key => $value2) { $typeid[].= $value2['id']; } } $result = db('channeltype') ->alias('a') ->join('arctype c','a.id = c.current_channel') ->where('c.is_del',0) ->whereIn('c.id',$typeid) ->orderRaw("FIELD(c.id, " . implode(',', $typeid) . ")") ->select(); $this->assign('result',$result); return $this->fetch('lanmu/list'); }
topid:顶级栏目字段
id:栏目数据表的栏目id
whereIn:用此进行数组条件查询
orderRaw:特殊排序条件
技术QQ交流群:157711366
技术微信:liehuweb
写评论