> Say I have an ancestry application where the users can enter
> parents, children, etc. The children have children, etc.
>
> table people
> id
> parent_id
>
> what is the best way to pull this from the db minimizing the
> number of queries to build a tree view of parents to children?
There is no simple way todo it with that model. (Unless you using Oracle, which
has CONNECT BY, or I believe there is patch for
postgres to achieve similar).
If you have a lot more reads of the data, you may want to change to a nested
set model, write operations take longer, but retrieving
the tree and rendering into a nested list only takes 1 query.
http://dev.mysql.com/tech-resources/articles/hierarchical-data.html for details.
Jared
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php