NAME
Tree::Persist::DB::SelfReferential - A handler for Tree persistence
SYNOPSIS
See "SYNOPSIS" in Tree::Persist or scripts/xml.demo.pl for sample code.
DESCRIPTION
This module is a plugin for Tree::Persist to store a Tree to a self-referential DB table. This is where a table contains an id column for the row and a parent_id column that refers back to another row's id (which is the parent row).
This is the simplest way to store a tree datastructure in a database, but it has performance penalties.
PARAMETERS
Parameters are used in the call to "connect({%opts})" in Tree::Persist or "create_datastore({%opts})" in Tree::Persist.
In addition to any parameters required by its parent Tree::Persist::DB, the following parameters are used by connect()
or create_datastore()
:
id (required)
This is the id for the root node of the tree. By specifying this, you can both store more that one tree in a table as well as only load a subtree.
id_col (optional)
This is the column name for the id field. It defaults to "id".
parent_id_col (optional)
This is the column name for the parent_id field. It defaults to "parent_id".
value_col (optional)
This is the column name for the value field. It defaults to "value".
class_col (optional)
This is the column name for the class field.
Methods
Tree::Persist::DB::SelfReferential is a sub-class of Tree::Persist::DB, and inherits all its methods.
TODO
Provide for a way to default the class to 'Tree' if no class_col is provided. Also, allow for the classname to be passed into the constructor.
CODE COVERAGE
Please see the relevant section of Tree::Persist.
SUPPORT
Please see the relevant section of Tree::Persist.
AUTHORS
Rob Kinyon <rob.kinyon@iinteractive.com>
Stevan Little <stevan.little@iinteractive.com>
Thanks to Infinity Interactive for generously donating our time.
Co-maintenance since V 1.01 is by Ron Savage <rsavage@cpan.org>. Uses of 'I' in previous versions is not me, but will be hereafter.
COPYRIGHT AND LICENSE
Copyright 2004, 2005 by Infinity Interactive, Inc.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.