RE: [PHP] PHP/MySQL best practice tutorial

From: Date: Tue, 29 Jul 2003 17:32:26 +0000
Subject: RE: [PHP] PHP/MySQL best practice tutorial
Groups: php.general 
Request: Send a blank email to php-general+get-157345@lists.php.net to get a copy of this message
Tony Crockford <mailto:tonyc@boldfish.co.uk> on Tuesday, July 29, 2003 10:23 AM said: > I have a mySQL database containing items that are categorised four > levels deep. [snip] > can anyone point me to a tutorial that would help me switch from > nested select statements to something more elegant? Try this article: http://www.sitepoint.com/article/1105/1 It details a method called Modified Preorder Tree Traversal. It's a fairly different way of thinking about hierarchical data when compared to the parent/child model. But once you understand what's happening it's quite elegant and fast. Using this method will also allow you to use more than 4 levels (if your heart so desires) of categorisation without having insanely complex sql select statements. Let me know if you get stuck on the concept (although the author does a good job of explaining it) and I'll see if I can help. Chris. p.s. While going through this article, I found that it helped immensely my understanding of the concept when I took my own data and created the tree by hand on a piece of paper, as opposed to just following his diagram with your eye. Creating your own tree with your own data on a piece of paper really helps you understand how things get ordered/numbered.

« previous php.general (#157345) next »