I've a little trouble while trying to get all ancestors from a node;
This is my 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
And this is how I'm trying to get all ancestors from a node (which is not a root)
$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
As $ancestors == false
I cannot iterate over it and get all ancestors (I'm trying to build a simple breadcrumb)
This is what I have stored in DB, this is real data (for testing puporse only)
+---------++---------++---------++---------++----------++---------+
|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 if Ancestors returns false, it means that the selected node is a root.
I've spent hours looking for a solution with no luck.
If you need further information, don't hesitate to ask for it!
EDIT: I've made a mistake when typing what is in the table, thanks to olivierw by alert me about this.