in reply to Re: Proper way to drilldown using DBIx::Class?
in thread Proper way to drilldown using DBIx::Class?
Howdy NetWallah! Thanks! I actually been lurking around PerlMonks for a long time and usually found what I needed. So I didn't need to post anything, until now. I'm sure I'll be posting again soon! 8uO I had to look up what dbicdump. I just copied and pasted everything from the DBIx::Class::Manual::Example doc. I'm just getting started on learning DBIx:Class, so outside of my one experiment. I have ventured outside of the examples at all. Your code was great!! Here's the code changes:
... And the Results:use strict; use lib qw( ... ); use MyDatabase::Main; my ($s_seconds, $s_microseconds) = gettimeofday; my $schema = MyDatabase::Main->connect('dbi:mysql:dbname=test', "xxxxxx", "XXXXX"); my $artistname = 'Michael Jackson'; my $artists_rs = $schema->resultset('Artist'); ## my $artists_rs = $schema->resultset('Artist')->search( ## { 'name' => "Micha +el Jackson" } ## ); while (my $a = $artists_rs->next) { print "Artist ID: ", $a->artistid, ".) ", $a->name, ".\n"; my $cd_rs = $a->cds; while (my $c = $cd_rs->next) { print " CD Id: ", $c->cdid, ".) ", $c->title, ".\n"; my $track_rs = $c->tracks; while (my $t = $track_rs->next) { print " ID: ", $t->trackid, ".) ", $t->title, ".\n"; } print "\n"; } ## CD's Loop. print "\n"; } ## Artists Loop. my ($e_seconds, $e_microseconds) = gettimeofday; my $elapsed = tv_interval( [$s_seconds, $s_microseconds], [$e_seconds, $e_microseconds] ); print "Elapsed:${elapsed}.\n";
Artist ID: 1.) Michael Jackson. CD Id: 1.) Thriller. ID: 3.) Billie Jean. ID: 6.) Beat It. CD Id: 2.) Bad. ID: 4.) Leave Me Alone. ID: 5.) Smooth Criminal. ID: 7.) Dirty Diana. Artist ID: 2.) Eminem. CD Id: 3.) The Marshall Mathers LP. ID: 1.) The Way I Am. ID: 2.) Stan. Artist ID: 3.) Nick Drake. CD Id: 4.) Pink Moon. ID: 9.) From the Morning. ID: 10.) Pink Moon. ID: 14.) Things Behind the Sun. CD Id: 6.) Bryter Layter. ID: 8.) Northern Sky. ID: 13.) Bryter Layter. Artist ID: 4.) The Doors. CD Id: 5.) LA Woman. ID: 11.) Riders on the Storm. ID: 12.) Love Her Madly. Elapsed:0.223685.
Bless you for your kindness and sharing! PS - Is there a place to check that your response was the correct answer (like stackoverflow.com)? Since you should get your creds
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Proper way to drilldown using DBIx::Class?
by NetWallah (Canon) on Jul 24, 2013 at 03:23 UTC | |
by ChuckP (Novice) on Jul 25, 2013 at 00:57 UTC |