Move Nested Set Node

Hi! Thanks for your reply.

You are right. I have mistaken the second select statement to be the folder I want to move INTO instead of the file that I want to move NEXT to.

Is there a way to specify the folder that I want to INTO since I only get the id of the folder I want to move INTO from the application?

Many thanks.

pheewww… I’m glad you got it working. I need a :drink:

The script that moves a node as child to a node will move that node and all its children “into” the target node only if the target node is a leaf node (has no children).

I haven’t written a script to move a node as a child to a target node where the target node has children. but it can be done. it’s just a matter of working out the logic to renumber the lft and rgt values accordingly.

so far I haven’t a need to do that and that is why I haven;t done it but there might scripts that do that somewhere on the www.

I use the nested set model for my categories table where the type of node is the same (a category). you have mixed node types and that is why I posted earlier

looking at your data model, I think you could be better off if you have one table for all your folders like root, c:, d:, _demo etc etc and another table for all the files in each each folder. each file will have a foreign key linking it to the id of the folder it belongs to in the folder table.

think of it as your folders being categories and the files being the products in each category.

anyway, just my :twocents:

and that could make your life easier since you have folders and files in your data model

ok. Many thanks for your advice. I buy you beer someday.

you’re welcome :slight_smile: