나는 각 사용자에게 부모 사용자와 자녀가있을 가능성이 있다고 생각하면 사용자와 모든 부모를 얻을 수있는 가능성이 있는지 알고 싶습니다.사용자의 부모를 얻으십시오
여기 내 사용자 엔티티 클래스입니다. 하지
내가xurshid29
에 동의
public function hasParent()
{
return $this->parent !== null;
}
public function getAncestry()
{
$ancestors = array();
$member = $this;
while ($member->hasParent())
{
$member = $member->getParent();
$ancestors[] = $member;
}
return $ancestors;
}
이 질문을 확인할 수 있습니까?이 사용자를 부모로, 그 다음 사용자 부모를 얻으려고하십니까? –
[this] (https://github.com/Atlantic18/DoctrineExtensions/blob/master/doc/tree.md)와 (과) 비슷한가요? – xurshid29