Re: Recursively determine parent records?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Chris Gregors wrote:
not to nit-pick:
1. I only do 1 sql query
2. Gijs Van Tulder uses recursion, while I use while loops. Similar
effect.
3. Gijs Van Tulder function only prints out the path as a series of
strings. I give it back in an array.

Actually, if you have more than one parent, you do more than one SQL query since I see WhoIsMyParent() in your code would have to be called multiple times to find multiple levels of parents. The code in the article only does a single query and only does it once (in the 2nd half of the article labelled "Modified Preorder Tree Traversal") and can retrieve an entire sub-tree in that one query, so all it has to do is fetch the results without needing to query more to find more than one parent. Which is great if you have a tree that might have parts with hundreds or thousands of levels of parents which still would only be one query away to retrieve.


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux