NAME
MKDoc::SQL::Category - Hierarchical ordrered category table object.
SUMMARY
MKDoc::SQL::Category is a subclass of MKDoc::SQL::Table, with the following differences:
The table MUST have a primary key of one field exactly
The table MUST have a field which represents the category path, i.e. /foo/bar/baz/
The table MUST have a nullable field which represents the category name, i.e. in /foo/bar/baz/ the category name is 'baz'.
The table MUST have a nullable field which represents the parent of the current category.
The table MUST have a non-null integer position field which stores how categories are ordered within a specific sub-category.
Moving a category into another category is fairly simple: Change the record's Parent_ID to the new parent and call $self->modify(); All the pathes of the current object and its children will be modified for you.
Apart from when you insert the root category '/'. you should _NEVER_ have to manually modify the full path field: this class manages it for you.
$class->new (%arguments);
MKDoc::SQL::Category->new (
name => $table_name,
pk => [ $name1 ],
cols => [ { name => $name1, type => $type1 },
{ name => $name2, type => $type2 } ],
unique => { $name1 => [ $col1, $col2 ] }
index => { $name2 => [ $col2 ] }
fk => { foreign_table => { source_col => target_col } }
ai => TRUE / FALSE
# extra mandatory options
category_id => "ID",
category_path => "Path",
category_name => "Name",
category_parent => "Parent_ID",
category_position => "Position"
);