PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Implementing An N-Level Nested Tree In PHP And PostgreSQL

Implementing An N-Level Nested Tree In PHP And PostgreSQL


Implementing An N-Level Nested Tree In PHP And PostgreSQL, Part 1

This series of articles is about implementing a nested tree using PHP and PostgreSQL. The theory and code in these articles also applies to MySQL, not just PostgreSQL. An N-Level nested tree is a way to represent hierarchical data, such as a list of directories and files in your operating system, or the listings in a directory such as the Open Directory Project. There can be any number of levels and any number of elements within each level. The goal is to be able lookup data in the tree as quickly as possible with minimal strain on resources. We will implementing this using the nested tree model by Joe Celko.

Implementing An N-Level Nested Tree In PHP And PostgreSQL, Part 2

This series of articles is about implementing a nested tree using PHP and PostgreSQL. This article - part 2 - covers the implementation of managing nested trees in PHP. The data we learned how to store in SQL in part 1 must be extracted somehow. In this article, we will create a class used to extract data from the tree and to rebuild the tree. Each portion of the class will be developed separately, then all combined into a single class.

Implementing An N-Level Nested Tree In PHP And PostgreSQL Appendix

Since creating the second part of the Nested Tree series, I've done further work on the nested tree class. This appendix article is not officially part of the "3 part series", but it is an addon article which may be continually updated with new ideas and snippets to include in the Nested Tree class. The reason these have been kept separate is because they are not core to the concept of implementing nested trees in your web site.
Download This Series
Download all articles in this series in PDF format with all listings and files.

Price: $8.00 AUD
(Approx. $8.00 USD)

More information