How do you convert a parent-child (adjacency) table to a nested set using PHP and MySQL?
I've spent the last few hours trying to find the solution to this question online. I've found plenty of examples on how to convert from nested set to adjacency... but few that go the other way around. The examples I have found either don't work or use MySQL procedures. Unfortunately, I can't use procedures for this project. I need a pure PHP solution. I have a table that uses the adjacency model below: id parent_id category 1 0 Books 2 0 CD's 3 0 Magazines 4 1 Books/Hardcover 5 1 Books/Large Format 6 3 Magazines/Vintage And I would like to convert it to a Nested Set table below: id left right