X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FManual%2FCookbook.pod;h=1d2b4c65666f6a38c436dd89f5fa68df9ee5ddda;hb=8ab99068d2201468f1fe8ed065ba9c0328e1b30c;hp=8bacb76313d0d4dd94af6724b6b93f3c95c39715;hpb=dfeba824c1e575d8629ca472c5fc5c28ef51b532;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Manual/Cookbook.pod b/lib/DBIx/Class/Manual/Cookbook.pod index 8bacb76..1d2b4c6 100644 --- a/lib/DBIx/Class/Manual/Cookbook.pod +++ b/lib/DBIx/Class/Manual/Cookbook.pod @@ -15,7 +15,6 @@ illustrate: # Set up inherited connection information package MyApp::DBIC; - use base qw/DBIx::Class/; __PACKAGE__->load_components(qw/PK::Auto::SQLite Core DB/); @@ -36,16 +35,16 @@ illustrate: sub books { my ($self) = @_; return MyApp::DBIC::Book->search( - { 'b2a.authID' => $self->authID }, { join => 'b2a' } - ); + { 'b2a.authID' => $self->authID }, # WHERE clause + { join => 'b2a' } # join condition (part of search attrs) # 'b2a' refers to the relationship named earlier in the Author class. # 'b2a.authID' refers to the authID column of the b2a relationship, # which becomes accessible in the search by being joined. + ); } # define the link table class package MyApp::DBIC::Book2Author; - use base qw/MyApp::DBIC/; __PACKAGE__->table('book2author'); @@ -56,7 +55,6 @@ illustrate: __PACKAGE__->belongs_to('bookID' => 'MyApp::DBIC::Book'); package MyApp::DBIC::Book; - use base qw/MyApp::DBIC/; __PACKAGE__->table('books'); @@ -69,7 +67,7 @@ illustrate: my ($self) = @_; return MyApp::DBIC::Author->search( { 'b2a.bookID' => $self->bookID }, # WHERE clause - { join => 'b2a' }); # Join condition + { join => 'b2a' }); # join condition (part of search attrs) } # So the above search returns an author record where the bookID field of the