//查找子集
function tree_son($data,$pid){
$son=[];
foreach ( $data as $key=>$vo){
if ($vo['pid']==$pid){
$vo['son']=tree_son($data, $vo['id']);
$son[]=$vo;
}
}
return $son;
}
public function _initialize(){
$menu=Db('access')->select();
$list=[];
foreach ($menu as $key=>$vo){
if ($vo['pid']==0){
$vo['son']=tree_son($menu,$vo['id']);
$list[]=$vo;
}
}
self::assign('menu',$list);
}