In the adjacency list model, every node will have a "parent" key, that will be NULL for root nodes.
The adjacency list model has the advantage of fast writes at the cost of slow reads. If you read more than you write, use nested set model instead
Like the nested set model the table should have a uniquie id which is serial (autoincremented)
if our tree salary table has the following structure
CREATE TABLE adj_table ( emp_id int(11) NOT NULL AUTO_INCREMENT, name varchar(30) NOT NULL, salary decimal(10,2) DEFAULT '0.00', boss_id int(11) DEFAULT NULL, PRIMARY KEY (emp_id) );
then the appropriate settings should be:
<?php ... // set the table and primary key $tree->table = 'adj_table'; $tree->setPrimaryKeyId('emp_id'); // set tree model and table configuration $tree->setTreeModel('adjacency'); $tree->setTableConfig(array('id'=>'emp_id', 'parent'=>'boss_id')); ... ?>