NAME DBIx::DBStag - Relational Database to Hierarchical
(Stag/XML) Mapping SYNOPSIS use DBIx::DBStag; my $dbh =
DBIx::DBStag->connect("dbi:Pg:dbname=moviedb"); my $sql = q[
SELECT studio.*, movie.*, star.* FROM studio NATURAL JOIN movie
NATURAL JOIN movie_to_star NATURAL JOIN star WHERE movie.genre =
'sci-fi' AND star.lastname = 'Fisher' USE NESTING
(set(studio(movie(star)))) ]; my $dataset =
$dbh->selectall_stag($sql); my @studios = $dataset->get_studio;
# returns nested data that looks like this - # # (studio # (name
"20th C Fox") # (movie # (name "star wars") (genre "sci-fi") #
(star # (firstname "Carrie")(lastname "Fisher"))))) # iterate
through result tree - foreach my $studio (@studios) { printf
"STUDIO: %s\n", $studio->get_name; my @movies =
$studio->get_movie; foreach my $movie (@movies) { printf "
MOVIE: %s (genre:%s)\n", $movie->get_name, $movie->get_genre; my
@stars = $movie->get_star; foreach my $star (@stars) { printf "
STARRING: %s:%s\n", $star->get_firstname, $star->get_lastname; }
} } # manipu