노드에서 모든 조상을 가져 오는 동안 약간의 문제가 있습니다. Doctrine 1.2 및 Symfony 1.4를 사용하여 노드 조상 얻기
이
내 schema.yml 파일입니다 :Constante:
connection: doctrine
tableName: constante
actAs:
NestedSet:
hasManyRoots: true
rootColumnName: parent_id
columns:
id:
type: integer(8)
fixed: false
unsigned: false
primary: true
autoincrement: true
parent_id:
type: integer(8)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
lft:
type: integer(8)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
rgt:
type: integer(8)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
level:
type: integer(8)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
cod_interno:
type: string(5)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
nombre:
type: string(64)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
그리고 이것은 내가 $ancestors == false
I로
$path = Doctrine_Core::getTable('Constante')->find($condicion); // $condicion = 57
$node = $path->getNode();
$isLeaf = $node->isLeaf(); //var_dump throws true
$ancestors = $node->getAncestors(); //var_dump throws false
$isValidNode = $node->isValidNode(); //var_dump throws true
(루트가 아닌 한) 노드의 모든 조상을 얻으려고하는 방법이다 그것을 반복하고 조상을 얻지 못한다. (단순한 빵 부스러기를 만들려고 노력하고있다.)
이것이 DB에 저장되어있다. 이것은 실제 데이터이다. (전용 테스트 용)
+---------++---------++---------++---------++----------++---------+
|ID ||PARENT_ID||LFT ||RGT ||LEVEL ||NOMBRE |
|---------||---------||---------||---------||----------||---------|
|56 ||56 ||1 ||4 ||0 ||COUNTRY | --> this is root
|57 ||56 ||2 ||3 ||1 ||CANADA | --> child of root
+---------++---------++---------++---------++----------++---------+
According to this Ancestors가 false를 반환하면 선택된 노드가 루트임을 의미합니다.
나는 운이없는 해결책을 찾기 위해 몇 시간을 보냈습니다.
추가 정보가 필요하면 언제든지 문의하십시오.
편집 : 테이블에 무엇을 입력 할 때 실수를했습니다. olivierw에게 감사드립니다.
좋아요! 하지만 왜'$ node-> getAncestors()'가 지금 작동하고 질문에서'false'를 반환하지 않는지 이해할 수 없습니다. –
안녕하세요. 나는이 함수를 처음부터 다시 작성했다. 이전 함수의 문제는 잘못된 명령문을 가진 setBaseQuery라고 생각한다. 나는 이것이 우아한 방법이라고 생각한다. –
'setBaseQuery'? 확실 해요! 이것은 우아한 방법입니다! –