来源:未知 时间:2016-10-25 09:39 作者:xxadmin 阅读:次
[导读] php无限级分类实现方法分析代码如下: 递归 publicfunctiongetInfo(){$data=$this-select();$arr=$this-noLimit($data,$f_id=0,$level=0);return$arr;}//无限极分类publicfunctionnoLimit($data,$f_id=0,$level=0){static$lists=array...
php无限级分类实现方法分析代码如下:
public function getInfo(){ $data=$this->select(); $arr=$this->noLimit($data,$f_id=0,$level=0); return $arr; } //无限极分类 public function noLimit($data,$f_id=0,$level=0){ static $lists=array(); foreach($data as $key=>$v){ if($v['f_id']==$f_id){ $v['level']=$level; $lists[]=$v; $this->noLimit($data,$v['q_id'],$level+1); } } return $lists; } 2. 普通 public function getInfo(){ $u_id=session('u_id'); $data=$this->join("user join user_role on user.u_id=user_role.u_id join role_quan on user_role.j_id=role_quan.j_id join quan on quan.q_id=role_quan.q_id")-> where("user.u_id=$u_id and quan.f_id=0")->group("quan.q_id")->select(); foreach($data as $k=>$v){ $arr=$this->join("user join user_role on user.u_id=user_role.u_id join role_quan on user_role.j_id=role_quan.j_id join quan on quan.q_id=role_quan.q_id")-> where("user.u_id=$u_id and quan.f_id=".$v['q_id'])->group("quan.q_id")->select(); $data[$k]['son']=$arr; } |
自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习
京ICP备14009008号-1@版权所有www.zixuephp.com
网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com