RE: [PEAR-DEV] Pear::Tree - Questions and feature requests
| From: | Simon H | Date: | Sat, 26 Jul 2003 10:53:16 +0000 |
| Subject: | RE: [PEAR-DEV] Pear::Tree - Questions and feature requests | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-18727@lists.php.net to get a copy of this message | ||
Sorry about the delay in getting back to you but I have been trying out
these methods.
The memory method you suggest is cool, but the only problem I have found
is that it creates a huge array, where [parent] and [children] create
full arrays of the tree also.
Is it possible to remove the [parent] bit and only have [children]
display its children and their children etc, building a simple nested
tree from the top down only, instead of walking up and down through the
whole tree for each child node? Maybe I'm still missing something?
Sorry about the hassle and thanks!
--
Simon H
> -----Original Message-----
> From: Wolfram Kriesing [mailto:wolfram@visionp.de]
> Sent: 21 July 2003 19:02
> To: Simon H
> Cc: 'PEAR Dev'
> Subject: Re: [PEAR-DEV] Pear::Tree - Questions and feature requests
>
>
> Simon H wrote:
> >>>1. getNestedTreeArray($root) method - producing a nested array of
> >>>elements based on parent l and r for positioning. (is this
> possible
> >>>already?
> >>
> >>there is a method
> >> getChildren($ids,$levels=1)
> >>which takes the level, which is actually the depth to return.
> >>that means if you say level=2 then it returns the element
> given by id
> >>and the children of 2 levels deep.
> >>is that what you are looking for?
> >
> >
> > Note quite...getChildren(1,2) gives...
>
> for Memory_DBNested the following also gives you
>
> > Array(
> > [0] => Array(
> > [0] => Array (
> > [id] => 2
> > [name] => A1
> > [comment] =>
> > [left] => 2
> > [right] => 8
> > [parentId] => 1
> [children] => which is an array of references
> to all the children data
> [parent] => which is a reference to the parent
> > )
> > [1] => Array (
> > [id] => 5
> > [name] => B1
> > [comment] =>
> > [left] => 3
> > [right] => 16
> > [parentId] => 2
> [children] => which is an array of references
> to all the children data
> [parent] => which is a reference to the parent
> > )
> > [2] => Array (
> > [id] => 3
> > [name] => A2
> > [comment] =>
> > [left] => 18
> > [right] => 29
> > [parentId] => 2
> [children] => which is an array of references
> to all the children data
> [parent] => which is a reference to the parent
> > )
> > )
> > )
> >
> > What I want is a nested tree array, like:
> >
> > Array(
> > [0] => Array(
> > [0] => Array (
> > [id] => 2 <<-----------------------+
> > [name] => A1 |
> > [comment] => |
> > [left] => 2 |
> > [right] => 8 |
> > [parentId] => 1 |
> > [children] => Array ( |
> > [0] => Array ( |
> > [id] => 5 |
> > [name] => B1 |
> > [comment] => |
> > [left] => 3 |
> > [right] => 16 |
> > [parentId] => 2 >--+
> > ) ^
> > [1] => Array ( |
> > [id] => 3 |
> > [name] => A2 |
> > [comment] => |
> > [left] => 18 |
> > [right] => 29 |
> > [parentId] => 2 >--+
> > )
> > )
> > )
> >
> > )
> > )
> >
> > Hope this clarifies things. Maybe I don't need the data
> this way? Any
> > suggestions on recursion?
>
> for Dynamic_DBNested its not this way i think
> does that help?
>
> --
> Wolfram
>
> ... opensource @ vision:produktion ...
> http://opensource.visionp.de
>
> ... authentication system ....
> http://sf.net/projects/auth
>