开发者

PHP Doctrine ORM NestedSet

开发者 https://www.devze.com 2022-12-22 17:44 出处:网络
although I read through the manual here: http://www.doctrine-project.org/documentation/manual/1_2/hu/hierarchical-data

although I read through the manual here: http://www.doctrine-project.org/documentation/manual/1_2/hu/hierarchical-data I couldn't find a way to move a node from a Leaf to b开发者_Python百科ecome a Root node. Any clues? The question is trivial for inserting a new node...but what about updating a node?


Use Doctrine_Node_NestedSet::makeRoot() like so:

$item->getNode()->makeRoot($maxRootValue + 1);

You need to pass new root_id value and one of the easiest way to do this is to select MAX(root_id) from table and increment its value.


As said Crozin, use Doctrine_Node_NestedSet::makeRoot(), but using the item's id instead of calculating the maximum value of the root_id.

The root_id is the id of the root node

$item->getNode()->makeRoot($item->id);

Is not necessary to calculate the value of root_id. Usign the item's id doesn't create any conflicts and is the way that Doctrine handled this internally.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号