while (true) 循环
//这是查询是否有上级
public static function getPaddress($address){ $res = self::where(['address'=>$address])->find(); if($res && $res['paddress']){ return $res['paddress']; }else{ return ''; } }
$my = $UserName; $arr = []; while (true) { $model_duser = new Duser(); $paddress = $model_duser->getPaddress($my); $plevel = Db::name("duser")->where(['address'=>$paddress])->find(); if (empty($paddress)) { array_push($arr,$paddress.'——等级名称(超级管理员'); break; } if ($plevel['id'] == 1) { array_push($arr,$paddress.'——等级名称(超级管理员)'); break; } $pnode = Db::name("node")->where(['id'=>$plevel['level']])->find(); $my = $paddress; array_push($arr,$my.'——等级名称('.$pnode['name'].')'); }
$this->view->assign('arr', $arr);
duser表有关于节点的字段,每个用户都有一个级别。
祝你开心=.=