jnewman / TreeTransform

Convert an adjacency list to a nested set adjacency list combo.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TreeTransform

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:

  1. RedBeanPHP is configured to use the R facade.
  2. The targeted TABLE contains a properly formed adjacency list with `parent` being the column name of the self-join foreign key.
  3. 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:

  1. Create a database and fill with the example data.
  2. Configure ./config/config.php (you need your password and databasename).

Hope this turns out to be useful.

About

Convert an adjacency list to a nested set adjacency list combo.


Languages

Language:PHP 100.0%