thinkphp代码实在看不懂,谁能给下边这些代码每一步都写上注释,本人新手,在此十分感谢
publicfunctionxxww(){$m=M('user');$userid=session('userid');$num=M('user')->where('pa...
public function xxww(){
$m=M('user');
$userid=session('userid');
$num=M('user')->where('parent_id='.$userid)->count();
if($num<10){
$where='parent_id='.$userid;
}elseif($num<40){
$arrData=M('user')->where('parent_id='.$userid)->getField('userid',true);//一级
foreach($arrData as $v){
$in[] = $v;
}
$map1['parent_id'] = array('in', $in);
$arrData1=M('user')->where($map1)->getField('userid',true);//二级
array_push($in,$userid);
$map['parent_id'] = array('in', $in);
$where = $map;
}else{
$arrData=M('user')->where('parent_id='.$userid)->getField('userid',true);//一级
foreach($arrData as $v){
$in[] = $v;
}
//dump($in);
//array_push($in,$userid);
$map['parent_id'] = array('in', $in);
$arrData1=M('user')->where($map)->getField('userid',true);//二级
//dump($arrData1);
foreach($arrData1 as $v){
array_push($in,$v);
}
//dump($in);die;
array_push($in,$userid);
$map['parent_id'] = array('in', $in);
//dump($arrData1);die;
$where=$map;
}
$p=getpage($m,$where,12);
$arr=$m->where($where)->select();
/* $this->list=$list; */
$this->page=$p->show();
$this->assign('arr',$arr);
$this->assign('arrData1',$arrData1);
$this->display();
} 展开
$m=M('user');
$userid=session('userid');
$num=M('user')->where('parent_id='.$userid)->count();
if($num<10){
$where='parent_id='.$userid;
}elseif($num<40){
$arrData=M('user')->where('parent_id='.$userid)->getField('userid',true);//一级
foreach($arrData as $v){
$in[] = $v;
}
$map1['parent_id'] = array('in', $in);
$arrData1=M('user')->where($map1)->getField('userid',true);//二级
array_push($in,$userid);
$map['parent_id'] = array('in', $in);
$where = $map;
}else{
$arrData=M('user')->where('parent_id='.$userid)->getField('userid',true);//一级
foreach($arrData as $v){
$in[] = $v;
}
//dump($in);
//array_push($in,$userid);
$map['parent_id'] = array('in', $in);
$arrData1=M('user')->where($map)->getField('userid',true);//二级
//dump($arrData1);
foreach($arrData1 as $v){
array_push($in,$v);
}
//dump($in);die;
array_push($in,$userid);
$map['parent_id'] = array('in', $in);
//dump($arrData1);die;
$where=$map;
}
$p=getpage($m,$where,12);
$arr=$m->where($where)->select();
/* $this->list=$list; */
$this->page=$p->show();
$this->assign('arr',$arr);
$this->assign('arrData1',$arrData1);
$this->display();
} 展开
展开全部
$userid=session('userid');//获取session用户信息
$num=M('user')->where('parent_id='.$userid)->count();//查询一级条数
if($num<10){//条数小于10执行
$where='parent_id='.$userid;
}elseif($num<40){//满足子用户条数小于40
$arrData=M('user')->where('parent_id='.$userid)->getField('userid',true);//一级 查询
foreach($arrData as $v){
$in[] = $v;//获取到一级用户数组。
}
$map1['parent_id'] = array('in', $in);
$arrData1=M('user')->where($map1)->getField('userid',true);//二级
array_push($in,$userid);//合并数组
$map['parent_id'] = array('in', $in);
$where = $map;
追问
$p=getpage($m,$where,12);
$arr=$m->where($where)->select();
/* $this->list=$list; */
$this->page=$p->show();
$this->assign('arr',$arr);
$this->assign('arrData1',$arrData1);
$this->display();
}
这段能给也解释了吗?谢谢啦
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询