DBIx::Tree

Perl module for generating a tree from a self-referential table
Download

DBIx::Tree Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Brian Jepson
  • Publisher web site:
  • http://search.cpan.org/~bjeps/

DBIx::Tree Tags


DBIx::Tree Description

Perl module for generating a tree from a self-referential table When you've got one of those nasty self-referential tables that you want to bust out into a tree, DBIx::Tree is the module to check out. Assuming there are no horribly broken nodes in your tree and (heaven forbid) any circular references, this module will turn something like: food food_id parent_id ================== ======= ========= Food 001 NULL Beans and Nuts 002 001 Beans 003 002 Nuts 004 002 Black Beans 005 003 Pecans 006 004 Kidney Beans 007 003 Red Kidney Beans 008 007 Black Kidney Beans 009 007 Dairy 010 001 Beverages 011 010 Whole Milk 012 011 Skim Milk 013 011 Cheeses 014 010 Cheddar 015 014 Stilton 016 014 Swiss 017 014 Gouda 018 014 Muenster 019 014 Coffee Milk 020 011into: Food (001) Dairy (010) Beverages (011) Coffee Milk (020) Whole Milk (012) Skim Milk (013) Cheeses (014) Cheddar (015) Stilton (016) Swiss (017) Gouda (018) Muenster (019) Beans and Nuts (002) Beans (003) Black Beans (005) Kidney Beans (007) Red Kidney Beans (008) Black Kidney Beans (009) Nuts (004) Pecans (006)There are examples in the examples directory - one plain text example, and two Tk examples.SYNOPSIS use DBIx::Tree; # have DBIx::Tree build the necessary SQL from table & column names: my $tree = new DBIx::Tree(connection => $dbh, table => $table, method => sub { disp_tree(@_) }, columns => , start_id => $start_id); $tree->traverse; # alternatively, use your own custom SQL statement my $sql = $sql, method => sub { disp_tree(@_) }, columns => , start_id => $start_id); $tree->traverse; # or use an already prepared DBI statement handle: my $sth = $dbh->prepare($sql); my $tree = new DBIx::Tree(connection => $dbh, sth => $sth, method => sub { disp_tree(@_) }, columns => , start_id => $start_id); $tree->traverse; Requirements: · Perl


DBIx::Tree Related Software