Re: DB_NestedSet: Feature Request
| From: | Daniel Khan | Date: | Fri, 07 Nov 2003 08:43:56 +0000 |
| Subject: | Re: DB_NestedSet: Feature Request | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-23321@lists.php.net to get a copy of this message | ||
Simon H wrote:
[..]
Useful to navigate around the tree using the 'l' and 'r' columns, or perhaps just up and down the 'l' column and return false when at the top or bottom...either would be nice. METHOD: getNextNode($id, $keepAsArray = false, $aliasFields = true, $addSQL = array()) METHOD: getPreviousNode($id, $keepAsArray = false, $aliasFields = true, $addSQL = array()) My suggestions on how to get this info may be off, but they seem like logical additions since we now have the new getParent() method - to provide a full compliment of tree navigation tools. // confirm that the current node is a parent // return true/false METHOD: hasChildren($id) Maybe there are simple ways to get this info without adding the methods, but I haven't came across them yet.Well hasChildren() is rather simple. It's if($node['r']-1 != $node['l']) { echo 'Has children'; } else { echo 'No children'; } But it's no big deal to add this to the class. I agree that such tree traversal methods could be useful. It's allready on my agenda to look at php5's domXML methods to see which additional methods could be added. Explaination: Navigating trough a XML tree is quite equal to navigating trough a nested set. I am also planning to support XML import/export for backup purposes btw. So - more to come. Thanks for your suggestions - they make sense. greetings -- daniel Khan