NYCPHP Meetup

NYPHP.org

[nycphp-talk] Building trees

Steve Manes smanes at magpie.com
Thu Jul 27 18:34:08 EDT 2006


Brian O'Connor wrote:
> Right now I'm building a site that has a "tree" like structure, and 
> right now in order to get the children I'm using a recursive function to 
> get them all, works fine, but that strikes me as inefficient and I'm 
> trying to find a way to get it with one query, rather than a variable 
> amount of queries based on how many 'events' a user has.

If you're using PostgreSQL, I highly recommend loading the 'tablefunc' 
package in the /contrib directory.  It includes support for an 
Oracle-like CONNECT BY/START WITH, which makes supporting a tree 
structure easy-breezy.




More information about the talk mailing list