--- In [email protected], "timgerr" <[EMAIL PROTECTED]> wrote: > > Amy, as always, you rock, that url was a good read. My problem is I > am not sure how many children I will have or what the structure will > look like. I am doing a tree so I can have n number of nodes or > children, and I am not sure how to build the return object/array.
Your app will probably perform better if you don't try to build the whole tree at once. But you might want to google on "recursion". Essentially, the principle is to use a function that works on an object in such a way that if the object has children, the function will call itself again for each child. That's not as difficult as it sounds, once you get your head around it--you just have to trust the recursion to do its thing and not force it. Probably someone has even posted some recursive PHP examples. Another way to approach it is to use the composite pattern and just populate the first level of objects, then once each object is instantiated it will start pulling down its own children and so on. This is sort of how I handle it, but I didn't make it where that always happens automatically so that if those resources are needed for something else the process can be interrupted. Oh, and one last thing...if your database technology isn't set in stone, you might want to consider using SQL Server, because Shape queries are made for this. AFAIK, other databases don't have anything that does this quite so nicely. HTH; Amy

