-
Notifications
You must be signed in to change notification settings - Fork 2
Use custom database table fields
Benjamin Kaiser edited this page Apr 15, 2021
·
9 revisions
If you want to use a custom database table or fields, you can define them via the constructor of the F3_Tree class:
F3_Tree( resource &$link , [ string $table_name = 'f3tree'] , [ string $id_column = 'id'] , [ string $title_column = 'title'] , [ string $left_column = 'lft_id'] , [ string $right_column = 'rgt_id'] , [ string $parent_column = 'parent_id'] )
So if you want to change the table name, simple pass it to the class constructor as the second parameter:
$f3t = new F3_Tree($f3->get('DB'), '[ custom_table_name ]');
You can also do this for all fields in the database table. So for example if you want to use a table called "category" with the following filenames:
Type | Fieldname |
---|---|
integer(11) | id |
varchar(50) | name |
integer(11) | lft |
integer(11) | rgt |
integer(11) | parent |
to store the tree structure, you can do this by passing the following parameters to the class constructor:
$f3t = new F3_Tree($f3->get('DB'), 'category', 'id', 'name', 'lft', 'rgt', 'parent');