item => head2 in docs
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Manual / Cookbook.pod
index 8bacb76..57c2175 100644 (file)
@@ -1,21 +1,24 @@
 =head1 NAME 
 
-DBIx::Class::Manual::Cookbook - Misc receipes
+DBIx::Class::Manual::Cookbook - Misc recipes
 
-=over 4
+=head1 DESCRIPTION
 
-=item Input validation.
+Things that could be handy
 
-=item Using joins
+=head1 RECIPES
 
-=item Many-to-many relationships
+=head2 Input validation.
+
+=head2 Using joins
+
+=head2 Many-to-many relationships
 
 This is not as easy as it could be, but it's possible. Here's an example to 
 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 +39,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 +59,6 @@ illustrate:
        __PACKAGE__->belongs_to('bookID' => 'MyApp::DBIC::Book');
 
        package MyApp::DBIC::Book;
-
        use base qw/MyApp::DBIC/;
 
        __PACKAGE__->table('books');
@@ -69,15 +71,15 @@ 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
        # book2author table equals the bookID of the books (using the bookID 
        # relationship table
 
-=item Advanced Exception handling
+=head2 Advanced Exception handling
 
-=item Transactions
+=head2 Transactions
 
 =back