Fix Bug #42034
[catagits/Catalyst-Manual.git] / lib / Catalyst / Manual / Tutorial / MoreCatalystBasics.pod
index 5af6537..1c6f48f 100644 (file)
@@ -174,7 +174,7 @@ as images and CSS files under the development server.
 
 =back
 
-For out application, we want to add one new plugin into the mix.  To 
+For our application, we want to add one new plugin into the mix.  To 
 do this, edit C<lib/MyApp.pm> (this file is generally referred to as 
 your I<application class>) and delete the line with:
 
@@ -190,6 +190,21 @@ Then replace it with:
             StackTrace
         /);
 
+B<Note:> Recent versions of C<Catalyst::Devel> have used a variety of 
+techniques to load these plugins/flags.  If you are following along in 
+Ubuntu 8.10, you should have C<Catalyst::Devel> v1.07 and see the 
+default code shown above.  If you are using v1.08, you should see the 
+following by default:
+
+    use Catalyst qw/-Debug
+                ConfigLoader
+                Static::Simple/;
+    ...
+    __PACKAGE__->setup();
+
+Don't let these variations confuse you -- they all accomplish the same 
+result.
+
 This tells Catalyst to start using one new plugin, 
 L<Catalyst::Plugin::StackTrace|Catalyst::Plugin::StackTrace>, to add a 
 stack trace to the standard Catalyst "debug screen" (the screen 
@@ -343,7 +358,7 @@ information, configuration values, a CSS stylesheet, and more.
 
 While TTSite is useful to bootstrap a project, most in the Catalyst 
 community recommend that it's easier to learn both Catalyst and 
-Tempalte Toolkit if you use the more basic TT approach.  Consequently, 
+Template Toolkit if you use the more basic TT approach.  Consequently, 
 this tutorial will use "plain old TT."
 
 Enter the following command to enable the C<TT> style of view
@@ -383,7 +398,7 @@ And update it to match:
 B<NOTE:> Make sure to add a comma after '.tt2' outside the single
 quote.
 
-This changes the default extenstion for Template Toolkit from '.tt' to
+This changes the default extension for Template Toolkit from '.tt' to
 '.tt2' and changes the base directory for your template files from
 C<root> to C<root/src>.
 
@@ -553,16 +568,16 @@ your OS command prompt.
 
 =head1 DATABASE ACCESS WITH C<DBIx::Class>
 
-Catalyst can be used with virtually any form of persistent datastore
-available via Perl.  For example,
-L<Catalyst::Model::DBI|Catalyst::Model::DBI> can be used to
-easily access databases through the traditional Perl C<DBI> interface.
-However, most Catalyst applications use some form of ORM technology to
-automatically create and save model objects as they are used.  Although
-Tony Bowden's L<Class::DBI|Class::DBI> has been a popular choice
-in the past, Matt Trout's L<DBIx::Class|DBIx::Class> (abbreviated
-as "DBIC") has rapidly emerged as the Perl-based ORM technology of choice.
-Most new Catalyst applications rely on DBIC, as will this tutorial.
+Catalyst can be used with virtually any form of persistent datastore 
+available via Perl.  For example, 
+L<Catalyst::Model::DBI|Catalyst::Model::DBI> can be used to easily 
+access databases through the traditional Perl C<DBI> interface. However, 
+most Catalyst applications use some form of ORM technology to 
+automatically create and save model objects as they are used.  Although 
+L<Class::DBI|Class::DBI> has been a popular choice in the past, Matt 
+Trout's L<DBIx::Class|DBIx::Class> (abbreviated as "DBIC") has rapidly 
+emerged as the Perl-based ORM technology of choice. Most new Catalyst 
+applications rely on DBIC, as will this tutorial.
 
 
 =head2 Create a Dynamic DBIC Model
@@ -587,8 +602,12 @@ to C<lib/MyApp/Schema.pm>.  Because we specified C<create=dynamic> to
 the helper, it use 
 L<DBIx::Class::Schema::Loader|DBIx::Class::Schema::Loader> to 
 dynamically load the schema information from the database every time 
-the application starts. And finally, C<dbi:SQLite:myapp.db> is the 
-standard DBI connect string for use with SQLite.
+the application starts. DBIC uses the schema to load other classes 
+that represent the tables in your database (DBIC refers to these 
+"table objects" as "result sources," see 
+L<DBIx::Class::ResultSource|DBIx::Class::ResultSource>). And finally, 
+C<dbi:SQLite:myapp.db> is the standard DBI connect string for use with 
+SQLite.
 
 B<NOTE:> Although the C<create=dynamic> option to the DBIC helper
 makes for a nifty demonstration, is only really suitable for very
@@ -598,8 +617,8 @@ use the C<create=static> option that we switch to below.
 
 =head1 ENABLE THE MODEL IN THE CONTROLLER
 
-Open C<lib/MyApp/Controller/Books.pm> and uncomment the model code we
-left disabled earlier (uncomment the line containing
+Open C<lib/MyApp/Controller/Books.pm> and un-comment the model code we
+left disabled earlier (un-comment the line containing
 C<[$c-E<gt>model('DB::Books')-E<gt>all]> and delete the next 2 lines):
 
     =head2 list
@@ -624,9 +643,27 @@ C<[$c-E<gt>model('DB::Books')-E<gt>all]> and delete the next 2 lines):
         $c->stash->{template} = 'books/list.tt2';
     }
 
-B<TIP>: You may see the C<$c-E<gt>model('DB::Book')> uncommented above
-written as C<$c-E<gt>model('DB')-E<gt>resultset('Book')>.  The two
-are equivalent.
+
+B<TIP>: You may see the C<$c-E<gt>model('DB::Book')> un-commented 
+above written as C<$c-E<gt>model('DB')-E<gt>resultset('Book')>.  The 
+two are equivalent.  Either way, C<$c-E<gt>model> returns a 
+L<DBIx::Class::ResultSet|DBIx::Class::ResultSet> which handles queries 
+against the database and iterating over the set of results that are 
+returned.
+
+We are using the C<-E<gt>all> to fetch all of the books.  DBIC 
+supports a wide variety of more advanced operations to easily do 
+things like filtering and sorting the results.  For example, the 
+following could be used to sort the results by descending title:
+
+    $c->model('DB::Books')->search({}, {order_by => 'title DESC'});
+
+Some other examples are provided in 
+L<DBIx::Class::Manual::Cookbook/Complex WHERE clauses>, with 
+additional information found at L<DBIx::Class::ResultSet/search>, 
+L<DBIx::Class::Manual::FAQ/Searching>, 
+L<DBIx::Class::Manual::Intro|DBIx::Class::Manual::Intro> 
+and L<Catalyst::Model::DBIC::Schema|Catalyst::Model::DBIC::Schema>.
 
 
 =head2 Test Run The Application
@@ -733,7 +770,7 @@ Next, to view the book list, change the URL in your browser to
 L<http://localhost:3000/books/list>. You should get a list of the five
 books loaded by the C<myapp01.sql> script above without any formatting.
 The rating for each book should appear on each row, but the "Author(s)"
-column will sitll be blank (we will fill that in later).
+column will still be blank (we will fill that in later).
 
 Also notice in the output of the C<script/myapp_server.pl> that DBIC
 used the following SQL to retrieve the data:
@@ -1285,7 +1322,7 @@ Kennedy Clark, C<hkclark@gmail.com>
 
 Please report any errors, issues or suggestions to the author.  The
 most recent version of the Catalyst Tutorial can be found at
-L<http://dev.catalyst.perl.org/repos/Catalyst/trunk/Catalyst-Manual/lib/Catalyst/Manual/Tutorial/>.
+L<http://dev.catalyst.perl.org/repos/Catalyst/Catalyst-Manual/5.70/trunk/lib/Catalyst/Manual/Tutorial/>.
 
 Copyright 2006-2008, Kennedy Clark, under Creative Commons License
 (L<http://creativecommons.org/licenses/by-sa/3.0/us/>).