Here is the TreeTransform package. Really it's just a class and a quick example. Ported from the answer to this StackOverflow question: http://goo.gl/J60wf Here are my ridiculous assumptions:
- RedBeanPHP is configured to use the R facade.
- The targeted TABLE contains a properly formed adjacency list with `parent` being the column name of the self-join foreign key.
-
TABLE contains two, otherwise unused, integer columns named `lft`
* and `rht` (e.g., table contains contains, at least, these fields:
CREATE TABLE IF NOT EXISTS `adjacency_nested_combo` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `parent` int(11) unsigned DEFAULT NULL, `lft` int(10) unsigned NOT NULL, `rht` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
</li>
If you want to try it out just do the following:
- Create a database and fill with the example data.
- Configure ./config/config.php (you need your password and databasename).