1
0
mirror of synced 2024-12-15 07:36:03 +03:00
doctrine2/manual/docs/Object relational mapping - Hierarchical data - Nested set - Setting up.php

27 lines
798 B
PHP
Raw Normal View History

2007-04-14 01:49:11 +04:00
To set up your model as Nested Set, you must add the following code to your model's table definition.
<code type="php">
class Menu extends Doctrine_Record {
public function setTableDefinition() {
$this->setTableName('menu');
// add this your table definition to set the table as NestedSet tree implementation
$this->option('treeImpl', 'NestedSet');
$this->option('treeOptions', array());
// 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');
}
}
</code>