You are here: RE: [PHP] recursive queries-tree view implementation « PHP « IT news, forums, messages
RE: [PHP] recursive queries-tree view implementation

Posted by "Jared Williams" on 11/19/05 00:03

> 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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация