DBIx::PathDBIx::Path is a Perl module used to resolve a path in an in-database tree or directed graph. | |
Download |
DBIx::Path Ranking & Summary
Advertisement
- License:
- Perl Artistic License
- Price:
- FREE
- Publisher Name:
- Brent Royal-Gordon
- Publisher web site:
- http://search.cpan.org/~brentdax/DBIx-Path-0.03/lib/DBIx/Path.pm
DBIx::Path Tags
DBIx::Path Description
DBIx::Path is a Perl module used to resolve a path in an in-database tree or directed graph. DBIx::Path is a Perl module used to resolve a path in an in-database tree or directed graph.SYNOPSIS use DBIx::Path; my $root=DBIx::Path->new(dbh => $dbh, table => 'treetable'); my $node=$root->resolve(split '/', 'one/two/three') or die "Can't resolve path: $! at $DBIx::Path::FAILED"; print $_->name, "t", $_->id, "n" for $node->list;DBIx::Path is used to navigate through trees or directed graphs described by self-referential SQL database tables. It can be used to browse most trees where each row contains a unique ID and the ID of its parent, as well as graphs structured similarly but with multiple parents for a given node (presumably with the actual data for a given ID stored in a different table).The module is designed to work with tables with at least three columns. One is called the parent ID (pid); one is called the name; and one is the ID. The combination of a particular pid and name must be unique in the entire table. The three columns can be of any type, but pid and id should probably be of the same type. The columns can have any name you want--you're not confined to "id", "pid", and "name". It is possible to have the id and name be the same column.An example layout: CREATE TABLE tree ( pid INTEGER NOT NULL, name VARCHAR(16) NOT NULL, id INTEGER NOT NULL, PRIMARY KEY (pid, name) )In MySQL, you might want to use a layout with a TIMESTAMP column: CREATE TABLE tree ( pid INTEGER NOT NULL, name VARCHAR(16) NOT NULL, id INTEGER NOT NULL, mtime TIMESTAMP, PRIMARY KEY (pid, name) )In this table, name and ID are one: CREATE TABLE folders ( parent VARCHAR(16) NOT NULL, name VARCHAR(16) NOT NULL, PRIMARY KEY (pid, name) )The parent/child relationship is expressed through the pid field--each node contains its parent's ID in its pid field. DBIx::Path's primary purpose is to retrieve the ID for a particular pid/name combination, with the ability to descend through the tree via the resolve method.An object of type DBIx::Path represents a node, and in this document it will always be referred to as a node. Requirements: · Perl
DBIx::Path Related Software