in reply to Proper way to drilldown using DBIx::Class?

Welcome to the Monastery !

Have you regenerated your schema using 'dbicdump' after making changes ?

This is the biggest operatioal change when moving from Class:DBI , where that step is not required.

FYI - here is a very similar functioning baby app I wrote when learning this stuff (which I have subsequently forgotten):

use strict; use warnings; use MusicApp::Schema; #MusicApp::Schema::Result::Band->has_many( albums => 'MusicApp::Schema +::Result::Album', 'band');#{ 'foreign.band' => 'self.name' }); my $bandname = $ARGV[0] || "The Beatles"; my $DB_NAME="musicdb.sqlite"; my $schema = MusicApp::Schema->connect("dbi:SQLite:$DB_NAME"); my $bandrs = $schema->resultset('Band')->search({ name => { -like => +"\%$bandname\%" } }) ; while (my $b = $bandrs->next){ print "BAND: ",$b->name, " Started ", $b->year,"\n"; my $albumrs = $b->albums; while (my $a = $albumrs->next){ print "\tALBUM: ",$a->year,"\t",$a->name,"\n"; my $songrs = $a->songs; while (my $s = $songrs->next){ print "\t\tSONG: ",$s->track, "\t",$s->name,"\n"; } } }

             My goal ... to kill off the slow brain cells that are holding me back from synergizing my knowledge of vertically integrated mobile platforms in local cloud-based content management system datafication.

Replies are listed 'Best First'.
Re^2: Proper way to drilldown using DBIx::Class?
by ChuckP (Novice) on Jul 24, 2013 at 00:53 UTC

    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:

    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";
    ... And the Results:
    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

      You are quite welcome!

      PerlMonks does not have a "correct Answer" category - everything is based on reputation of the node - You can credit me by upvoting (++) my writeup.

      FYI - I upvoted yours, because you followed up with acknowldgement, and a a final. functioning solution for others to follow.

      Cheers! , and FYI - The Doors are one of my favourites. I was saddened when Ray Manzerek passed away 2 months ago.

                   My goal ... to kill off the slow brain cells that are holding me back from synergizing my knowledge of vertically integrated mobile platforms in local cloud-based content management system datafication.

        Howdy Netwallah,
        I don't think I have voting rights yet. I don't see any ++ around your replies. Bummer! It looks like they give you votes until after so many posts & as you move up through the ranks. Maybe, I can wash some dishes to get some points. When I get voting rights, I promise to give you the first.

        The doors "L. A. Woman" was my first LP! Great Band and he was performed magic on the keyboards.
        Thanks Again your help!!