i have two trees in one table, but when i add a new node, the node not getting the parent tree_id,
in my case, my tree_id column is int. when it was first root, everything working fine, this will start happening when i added another root, and added nodes under it.
In a multi-tree table, you need to make sure the correct tree is selected before you run any operation on it.
On some operations, that work with existing objects, the Nestedset model will retrieve the current "tree_id" from the current object, but on others, you need to use the set_tree_id() method to define the tree_id of the tree you want to work with.
In general, if you add a node you will always do that relative to another node of the tree, either as a child of another object, or as a sibling:
// get the root of a specific tree $root = Model_Tree::forge()->set_tree_id($mytreeid)->root()->get_one();
// create a new record $child = Model_Tree::forge(array('name' => 'Child record'));
// add it as a child of the root $child->child($root)->save();
Note that you should not use the traditional ORM save() call:
// do not do this $child->save();
If you want do that, you have to make sure you manually assign a value to the "tree_id":
// but this $child->tree_id = $mytreeid; $child->save();
i did select exact parent, i assumed that the tree_id wil be set automatically as said in docs, but when ever i select tree with id 2, and created a child on it, it gets tree id 1, is it bug?
The nestedset model doesn't overload the ORM function of the find() method, so I can't see how a column value suddenly would change. What is the contents of the "original" array when you do