【小编推荐】人人商城获取所有的下级用户

2025-01-05   |   发布者:   |   查看:3320次

人人商城二次开发

使用了 最原始的方法。哈哈

     echo  $this->gesuoyouxiaji(3);// 输出4,7,5,1,2,6
    // 获取所有的下级   
		public function gesuoyouxiaji($uid)
		{
			global $_W, $_GPC;
			$agents='';
            $agents1 = pdo_fetch('select GROUP_CONCAT(id) AS id_list  from ' . tablename('ewei_shop_member') . ' where agentid in ('.$uid.')');//查找一级
                     print_r($agents1);
				if($agents1['id_list']!=''){
				    $agents=$agents1['id_list'];

					$agents2 = pdo_fetch('select GROUP_CONCAT(id) AS id_list  from ' . tablename('ewei_shop_member') . ' where agentid in ('.$agents1['id_list'].')');//查找2级
				    	print_r($agents2);
				  if($agents2['id_list']!=''){
				      $agents=$agents.','.$agents2['id_list'];

				    	$agents3 = pdo_fetch('select GROUP_CONCAT(id) AS id_list  from ' . tablename('ewei_shop_member') . ' where agentid in ('.$agents2['id_list'].')');//查找3级
				    	print_r($agents3);
				    if($agents3['id_list']!=''){
				      $agents=$agents.','.$agents3['id_list'];

				    	$agents4 = pdo_fetch('select GROUP_CONCAT(id) AS id_list  from ' . tablename('ewei_shop_member') . ' where agentid in ('.$agents3['id_list'].')');//查找4级
				    	print_r($agents4);
				  if($agents4['id_list']!=''){
				      $agents=$agents.','.$agents4['id_list'];

			    	}	
				    	
			    	}	
				    	

			    	}	
				}
				
		    return  $agents;
		}