Hierarchical data - Introduction - Setting up.php 832 Bytes
Newer Older
1 2

<code type="php">
3 4 5 6 7 8 9 10
class Menu extends Doctrine_Record { 
    public function setTableDefinition() {

        $this->setTableName('menu');

        // add this your table definition to set the table as NestedSet tree implementation
		// $implName is 'NestedSet' or 'AdjacencyList' or 'MaterializedPath'
		// $options is an assoc array of options, see implementation docs for options
11 12
        $this->option('treeImpl', $implName);
        $this->option('treeOptions', $options);
13 14 15 16 17 18 19 20 21 22 23
       
        // you do not need to add any columns specific to the nested set implementation, these are added for you
        $this->hasColumn("name","string",30);

    }
    
    // this __toString() function is used to get the name for the path, see node::getPath()
    public function __toString() {
        return $this->get('name');
    }
}
24
</code>