class nestedset_forum extends nestedset
Methods
__construct(driver_interface $db, db $lock, string $table_name)
Construct |
||
string |
get_sql_where(string $operator = 'AND', string $column_prefix = '')
Returns additional sql where restrictions |
from nestedset |
array |
insert(array $additional_data)
Inserts an item into the database table and into the tree. |
from nestedset |
array |
delete(int $item_id)
Delete an item from the tree and from the database table |
from nestedset |
bool |
move(int $item_id, int $delta)
Move an item by a given delta |
from nestedset |
bool |
move_down(int $item_id)
Move an item down by 1 |
from nestedset |
bool |
move_up(int $item_id)
Move an item up by 1 |
from nestedset |
bool |
move_children(int $current_parent_id, int $new_parent_id)
Moves all children of one item to another item |
from nestedset |
bool |
change_parent(int $item_id, int $new_parent_id)
Change parent item |
from nestedset |
array |
get_path_and_subtree_data(int $item_id, bool $order_asc = true, bool $include_item = true)
Get all items that are either ancestors or descendants of the item |
from nestedset |
array |
get_path_data(int $item_id, bool $order_asc = true, bool $include_item = true)
Get all of the item's ancestors |
from nestedset |
array |
get_subtree_data(int $item_id, bool $order_asc = true, bool $include_item = true)
Get all of the item's descendants |
from nestedset |
array |
get_path_basic_data(array $item)
Get basic data of all parent items |
from nestedset |
array |
get_all_tree_data(bool $order_asc = true)
Get all items from the tree |
from nestedset |
regenerate_left_right_ids(int $new_id, int $parent_id, bool $reset_ids = false)
Regenerate left/right ids from parent/child relationship |
from nestedset |
Details
at line 25
public
__construct(driver_interface $db, db $lock, string $table_name)
Construct
in nestedset at line 96
public string
get_sql_where(string $operator = 'AND', string $column_prefix = '')
Returns additional sql where restrictions
in nestedset at line 126
public array
insert(array $additional_data)
Inserts an item into the database table and into the tree.
in nestedset at line 205
public array
delete(int $item_id)
Delete an item from the tree and from the database table
Also deletes the subtree from the tree and from the database table
in nestedset at line 220
public bool
move(int $item_id, int $delta)
Move an item by a given delta
An item is only moved up/down within the same parent. If the delta is larger then the number of children, the item is moved to the top/bottom of the list of children within this parent.
in nestedset at line 338
public bool
move_down(int $item_id)
Move an item down by 1
in nestedset at line 346
public bool
move_up(int $item_id)
Move an item up by 1
in nestedset at line 354
public bool
move_children(int $current_parent_id, int $new_parent_id)
Moves all children of one item to another item
If the new parent already has children, the new children are appended to the list.
in nestedset at line 460
public bool
change_parent(int $item_id, int $new_parent_id)
Change parent item
Moves the item to the bottom of the new \parent's list of children
in nestedset at line 559
public array
get_path_and_subtree_data(int $item_id, bool $order_asc = true, bool $include_item = true)
Get all items that are either ancestors or descendants of the item
in nestedset at line 570
public array
get_path_data(int $item_id, bool $order_asc = true, bool $include_item = true)
Get all of the item's ancestors
in nestedset at line 580
public array
get_subtree_data(int $item_id, bool $order_asc = true, bool $include_item = true)
Get all of the item's descendants
in nestedset at line 634
public array
get_path_basic_data(array $item)
Get basic data of all parent items
Basic data is defined in the $itembasicdata property. Data is cached in the item_parents column in the item table
in nestedset at line 678
public array
get_all_tree_data(bool $order_asc = true)
Get all items from the tree
in nestedset at line 807
public
regenerate_left_right_ids(int $new_id, int $parent_id, bool $reset_ids = false)
Regenerate left/right ids from parent/child relationship
This method regenerates the left/right ids for the tree based on the parent/child relations. This function executes three queries per item, so it should only be called, when the set has one of the following problems: - The set has a duplicated value inside the left/right id chain - The set has a missing value inside the left/right id chain - The set has items that do not have a left/right id set
When regenerating the items, the items are sorted by parent id and their current left id, so the current child/parent relationships are kept and running the function on a working set will not change the order.