DB_NestedSet, where did my nested set go?

From: Date: Tue, 17 Apr 2007 19:29:58 +0000
Subject: DB_NestedSet, where did my nested set go?
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-27089@lists.php.net to get a copy of this message
Hello all, I have an odd problem with DB_NestedSet. When I gather output with the Menu driver, I seem to loose my data? (See code below) When I get the output object: $output = DB_NestedSet_Output::factory($parameters, 'Menu'); I get no erros, but when I do a var_dump on the object I don't see all my data I assigned (Check source code for var dump). When I return the structure from the output object $output->returnStructure(); => this returns an empty array. Please, can you help me? Alex My entire sourcecode: <pre> <?php //err error_reporting(E_ALL); $pear_dir = 'E:/Alex/Mijn Sites/Webserver/php/PEAR/'; /* use pear directory as include_path */ ini_set('include_path', $pear_dir); /* fetch sufficient files */ require_once('DB/NestedSet.php'); require_once("DB/NestedSet/Output.php"); require_once("HTML/Menu.php"); require_once('MDB2.php'); //dsn database connection $dsn = 'mysqli://root:root@localhost/test'; $table_match = array ( "category_id" => "id", "parent_id" => "rootid", "lft" => "l", "rgt" => "r", "ordernumber" => "norder", "level" => "level", "name" => "name" ); //define the tables $tables = array ( "node_table" => "nested_category", "lock_table" => "category_locks" ); //maak het object aan $nested_set = DB_NestedSet::factory('MDB2', $dsn, $table_match); $nested_set->setAttr($tables); //fetch all database nodes $data = $nested_set->getAllNodes(true); //this array returns proper output, I tested it print_r($data); foreach($data as $id => $node) { //add an ur; $data[$id]['url'] = "?node=" . $id; } print_r($data); /* returns (not the entire set, it would be too big) Array ( [1] => Array ( [id] => 1 [rootid] => 0 [l] => 1 [r] => 20 [norder] => 1 [level] => 0 [name] => ELECTRONICS ) [2] => Array ( [id] => 2 [rootid] => 1 [l] => 2 [r] => 9 [norder] => 1 [level] => 1 [name] => TELEVISIONS ) */ //set the parameters for output with HTML_Menu $parameters = array ( "structure" => $data, "titleField" => "name", "urlField" => "url" ); //fetch the output objct $output = DB_NestedSet_Output::factory($parameters, 'Menu'); var_dump($output); /* vardump returns: DB_NestedSet_Menuobject(DB_NestedSet_Menu)#5 (4) { ["_structMenu"]=> array(0) { } ["_paramDefaults"]=> array(3) { ["textField"]=> string(4) "text" ["titleField"]=> string(4) "name" ["urlField"]=> string(3) "url" } ["_structTreeMenu"]=> bool(false) ["options"]=> array(0) { } } */ $structure = $output->returnStructure(); /* $structure is an empty array here */ print_r($structure); $menu = new HTML_Menu($structure, 'sitemap'); $menu->show(); ?> </pre>

« previous php.pear.general (#27089) next »