最近做了的团队分红,用到了递归,我需要一级一级往上查,我遇到的问题是用$this如果上级不满足条件的话隔代的话就没有数据了, $this->getTree()和self::getTree()的区别是什么呢?
public function getTree($pid){
$pid = intval($pid);
if(empty($pid)){
return 1;
}
$top = pdo_fetch('select * from'.tablename('ewei_shop_member').'where id=:id',array(':id'=>$pid));//推荐人
if($top['isheads']!=1){//判断我的推荐人是不是队长
//return $this->getTree($top['headsid']);//原来的
return self::getTree($top['headsid']);//正确的
}else{
return $top['id'];//把推荐人返回去
}
}