php 查用戶所有上級/下級

php 查用戶所有上級


    function getDataFind($table,$where=[]){
        $data = Db::name($table)->where($where)->find();
        return $data;
    }
    //查找所有上級
    function getParent($uid){
        //當前用戶
        static $arr=[];
        //當前用戶
        $member = $this->getDataFind('member',array('uid'=>$uid));
        if ($member['parent_uid'] > 0){
            $parent = $this->getDataFind('member',array('uid'=>$member['parent_uid']));
            if ($parent['level'] > 4){//代理
                $arr[]=$parent['uid'] ;
            }
                $this->getParent($parent['parent_uid']);
        }
        return $arr;

    }

php 查所有下級

    //查詢所有下級
    function getSon($pid,$status = false){
        //當前用戶
       static $arr=[];
       if (!$status){$arr = [];}
        //當前用戶
        $son = $this->getDataFind('dynamic_comment',array('c_id'=>$pid));
         if ($son){
             $arr[] = $son['id'];
             $this->getSon($son['id'],true);
        }
             return $arr;
    }

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章