doc changes for tree configuration
This commit is contained in:
parent
02efd7f73b
commit
0d1d0ed4bf
@ -4,26 +4,7 @@
|
||||
require_once("../lib/Doctrine.php");
|
||||
|
||||
// autoloading objects, modified function to search drafts folder first, should run this test script from the drafts folder
|
||||
function __autoload($classname) {
|
||||
|
||||
if (class_exists($classname)) {
|
||||
return false;
|
||||
}
|
||||
if (! $path) {
|
||||
$path = dirname(__FILE__);
|
||||
}
|
||||
$classpath = str_replace('Doctrine_', '',$classname);
|
||||
|
||||
$class = $path.DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR,$classpath) . '.php';
|
||||
|
||||
if ( !file_exists($class)) {
|
||||
return Doctrine::autoload($classname);
|
||||
}
|
||||
|
||||
require_once($class);
|
||||
|
||||
return true;
|
||||
}
|
||||
spl_autoload_register(array('Doctrine', 'autoload'));
|
||||
|
||||
// define our tree
|
||||
class Menu extends Doctrine_Record {
|
||||
|
@ -7,7 +7,8 @@ class Menu extends Doctrine_Record {
|
||||
// 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
|
||||
$this->actsAsTree($implName, $options);
|
||||
$this->option('treeImpl', $implName);
|
||||
$this->option('treeOptions', $options);
|
||||
|
||||
// you do not need to add any columns specific to the nested set implementation, these are added for you
|
||||
$this->hasColumn("name","string",30);
|
||||
|
@ -5,8 +5,8 @@ class Menu extends Doctrine_Record {
|
||||
$this->setTableName('menu');
|
||||
|
||||
// add this your table definition to set the table as NestedSet tree implementation
|
||||
$options = array();
|
||||
$this->actsAsTree('NestedSet', $options);
|
||||
$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);
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
$options = array('has_many_roots' => true, // enable many roots
|
||||
'root_column_name' => 'root_id'); // set root column name, defaults to 'root_id'
|
||||
//use these options in the setTableDefinition
|
||||
$options = array('hasManyRoots' => true, // enable many roots
|
||||
'rootColumnName' => 'root_id'); // set root column name, defaults to 'root_id'
|
||||
|
||||
// To create new root nodes, if you have manually set the root_id, then it will be used
|
||||
// otherwise it will automatically use the next available root id
|
||||
|
Loading…
x
Reference in New Issue
Block a user