php - Getting node ancestors using Doctrine 1.2 and Symfony 1.4 -


i've little trouble while trying ancestors node;

this 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 how i'm trying ancestors node (which not 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 cannot iterate on , ancestors (i'm trying build simple breadcrumb)

this have stored in db, real data (for testing puporse only)

+---------++---------++---------++---------++----------++---------+ |id ||parent_id||lft ||rgt ||level ||nombre | |---------||---------||---------||---------||----------||---------| |56 ||56 ||1 ||4 ||0 ||country | --> root |57 ||56 ||2 ||3 ||1 ||canada | --> child of root +---------++---------++---------++---------++----------++---------+ 

according this if ancestors returns false, means selected node root.

i've spent hours looking solution no luck.

if need further information, don't hesitate ask it!

edit: i've made mistake when typing in table, olivierw alert me this.

it seems have error in rgt field in table. if id 56 root, should have rgt = 4 , id 57 should have rgt = 3. table should read:

+---------++---------++---------++---------++----------++---------+ |id ||parent_id||lft ||rgt ||level ||nombre | |---------||---------||---------||---------||----------||---------| |56 ||56 ||1 ||4 ||0 ||country | |57 ||56 ||2 ||3 ||1 ||canada | +---------++---------++---------++---------++----------++---------+ 

so ancestors correctly.


Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -