递归查询上级

//递归查询上级信息

直接上代码
    public function getpid($pid,$deploy=0){
        static $data=[];
        $result=Db::name('users')->where('id',$pid)->find();
        if($result['deploy_id']>$deploy){
            $data[]=$result;
        }
        if(count($data)<2){
            if($result['pid']){
                $this->getpid($result['pid'],$deploy=$result['deploy_id']);
            }
        }
        return $data;
    }

你可能感兴趣的:(javascript,sql)