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;
}