NYCPHP Meetup

NYPHP.org

[nycphp-talk] nested set tree sorting

Tim Lieberman tim_lists at o2group.com
Thu Jul 31 02:19:27 EDT 2008


 From memory  ... I don't think you can do it in SQL (but I very well  
may be wrong), at least on the query-end.

It's probably best to approach it by restructuring the tree when you  
insert/update, though that's going to be a good deal of hairy code in  
your business logic.

Sorry I don't have a better answer.

-Tim


On Jul 31, 2008, at 12:06 AM, Marc Antony Vose wrote:

> Hey there:
>
> I had a category structure that was previously limited to two  
> degrees, but I've decided that I want it to be able to grow however  
> it needs to.  I has been using a "parent" field previously, and I  
> converted it to be stored using a typical nested set model, so that  
> I could achieve display with a single database query, and so forth.
>
> I now have a slight problem, which is that I would like the  
> categories to be alphabetized in each level.  Has anyone previously  
> tackled this problem before, and have some sample code to rebuild  
> the entire tree, but alphabetize or sort the entries in each level?
>
> Cheers,
>
> Marc Vose
> Suzerain Studios
> http://www.suzerain.com
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php




More information about the talk mailing list