/**获取基准数据
* @param $ids 父id 多个逗号分隔
* @return array
*/
public function saleBase($ids)
{
$data=$this->table('member_user(a)')
->join('member_connect(b)',['a.user_id','b.user_id'])
->where(['_sql'=>'b.pid in('.$ids.')'])
->field(['a.*,b.pid'])
->limit(0)
->select();
return $data;
}
//获取遍历基准,循环深度获取数据
public function loadSaleUser($ids)
{
$data =$this->saleBase($ids);foreach($data as $k=>$v)
{
$this->num++;
$data[$k]['c'] = $this->loadNodes($v);
}
}
/**
* @param $v 传入基准,纵向递归,获取数据
* @return array返回结果集
*/
public function loadNodes($v)
{
$data = $this->saleBase($v['user_id']);
foreach($data as $k=>$v)
{
$this->num++;
$data[$k]['c'] = $this->loadNodes($v);
}
return $data;
}