Re: Nested database loops and completing an unordered list....

From: Date: Fri, 02 Mar 2012 12:43:23 +0000
Subject: Re: Nested database loops and completing an unordered list....
References: 1 2 3 4 5 6 7 8 9 10  Groups: php.general 
Request: Send a blank email to php-general+get-316834@lists.php.net to get a copy of this message
> My usual approach to a problem like this to to includes a parent column in the table > > ID (int pk) > Parent ( default null ) // no parent > Item > Itemtype > [etc] > > Parent will then hold either a null if a top level item, or a structured path ( 1/10/24 ) that > notes the parents of the item all the way up to the parent. That way, a single query will get you > all items in that parent's lineage to whatever depth is needed by using the child's value > > Select * from table where parent = '1/10' > > Would retrieve all items that are children of a top level of 1 and a second level of 10 I would do that under normal circumstance but I cannot modify the client's table in any way shape or form. I am considering the COMPANY_ID to be the parent at this point and I can get all who belong to a company. I just need to turn that lineage into a tree.

« previous php.general (#316834) next »