protected function recalculateTree()
	{
		if (!$this->nested_sets_enabled) {
			throw new \RuntimeException('Nested sets are disabled for this entity.');
		}

		$q_table     = $this->flupdo->quoteIdent($this->table);
		$cols        = $this->nested_sets_table_columns;
		$c_order_by  = $this->nested_sets_order_by;
		$c_id        = $this->flupdo->quoteIdent($cols['id']);
		$c_parent_id = $this->flupdo->quoteIdent($cols['parent_id']);
		$c_left      = $this->flupdo->quoteIdent($cols['left']);
		$c_right     = $this->flupdo->quoteIdent($cols['right']);
		$c_depth     = $this->flupdo->quoteIdent($cols['depth']);

		$set = $this->flupdo->select($c_id)
			->from($q_table)
			->where("$c_parent_id IS NULL")
			->orderBy($c_order_by)
			->query();

		$this->recalculateSubTree($set, 1, 0, $q_table, $c_order_by, $c_id, $c_parent_id, $c_left, $c_right, $c_depth);
	}
protected function recalculateTree()
	{
		if (!$this->nested_sets_enabled) {
			throw new \RuntimeException('Nested sets are disabled for this entity.');
		}

		$q_table     = $this->flupdo->quoteIdent($this->table);
		$cols        = $this->nested_sets_table_columns;
		$c_order_by  = $this->nested_sets_order_by;
		$c_id        = $this->flupdo->quoteIdent($cols['id']);
		$c_parent_id = $this->flupdo->quoteIdent($cols['parent_id']);
		$c_left      = $this->flupdo->quoteIdent($cols['left']);
		$c_right     = $this->flupdo->quoteIdent($cols['right']);
		$c_depth     = $this->flupdo->quoteIdent($cols['depth']);

		$set = $this->flupdo->select($c_id)
			->from($q_table)
			->where("$c_parent_id IS NULL")
			->orderBy($c_order_by)
			->query();

		$this->recalculateSubTree($set, 1, 0, $q_table, $c_order_by, $c_id, $c_parent_id, $c_left, $c_right, $c_depth);
	}
protected function recalculateTree ( ) { if ( ! $ this -> nested_sets_enabled ) { throw new \ RuntimeException ( 'Nested sets are disabled for this entity.' ) ; } $ q_table = $ this -> flupdo -> quoteIdent ( $ this -> table ) ; $ cols = $ this -> nested_sets_table_columns ; $ c_order_by = $ this -> nested_sets_order_by ; $ c_id = $ this -> flupdo -> quoteIdent ( $ cols [ 'id' ] ) ; $ c_parent_id = $ this -> flupdo -> quoteIdent ( $ cols [ 'parent_id' ] ) ; $ c_left = $ this -> flupdo -> quoteIdent ( $ cols [ 'left' ] ) ; $ c_right = $ this -> flupdo -> quoteIdent ( $ cols [ 'right' ] ) ; $ c_depth = $ this -> flupdo -> quoteIdent ( $ cols [ 'depth' ] ) ; $ set = $ this -> flupdo -> select ( $ c_id ) -> from ( $ q_table ) -> where ( "$c_parent_id IS NULL" ) -> orderBy ( $ c_order_by ) -> query ( ) ; $ this -> recalculateSubTree ( $ set , 1 , 0 , $ q_table , $ c_order_by , $ c_id , $ c_parent_id , $ c_left , $ c_right , $ c_depth ) ; }
Recalculate nested-sets tree indices

To use this feature a parent, left, right and depth columns must be specified.

Composed primary keys are not supported yet.

Three extra columns are required: tree_left, tree_right, tree_depth
(ints, all nullable). This function will update them according to id
and parent_id columns.
Recalculate nested - sets tree indices