X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Manual.git;a=blobdiff_plain;f=lib%2FCatalyst%2FManual%2FTutorial%2FMoreCatalystBasics.pod;h=7e54dcb0be39a400239e6f907ad182e1717be3e9;hp=41f58bd12d654fb0cc87cfd93f4da42a316c8eca;hb=3b1fa91be1d89d2297aa9e8e83462344d9cd9820;hpb=325bc0fd9f3c14fc336ddc74fdaa42e18aa3b4fe diff --git a/lib/Catalyst/Manual/Tutorial/MoreCatalystBasics.pod b/lib/Catalyst/Manual/Tutorial/MoreCatalystBasics.pod index 41f58bd..7e54dcb 100644 --- a/lib/Catalyst/Manual/Tutorial/MoreCatalystBasics.pod +++ b/lib/Catalyst/Manual/Tutorial/MoreCatalystBasics.pod @@ -190,11 +190,11 @@ Then replace it with: # Load plugins use Catalyst qw/-Debug - ConfigLoader - Static::Simple + ConfigLoader + Static::Simple - StackTrace - /; + StackTrace + /; B Recent versions of C have used a variety of techniques to load these plugins/flags. For example, you might see @@ -213,6 +213,14 @@ L output appears in your browser, not in the console window from which you're running your application, which is where logging output usually goes. +Make sure that when adding new plugins that you include them as a new +dependancies within the Makefile.PL file. For example, after adding +the StackTrace plugin the Makefile.PL should include the following +line: + + requires 'Catalyst::Plugin::StackTrace'; + + B =over 4 @@ -273,7 +281,7 @@ and add the following method to the controller: # Retrieve all of the book records as book model objects and store in the # stash where they can be accessed by the TT template - # $c->stash->{books} = [$c->model('DB::Books')->all]; + # $c->stash->{books} = [$c->model('DB::Book')->all]; # But, for now, use this code until we create the model later $c->stash->{books} = ''; @@ -559,18 +567,18 @@ C in your editor and enter: -- -- Create a very simple database to hold book and author information -- - CREATE TABLE books ( + CREATE TABLE book ( id INTEGER PRIMARY KEY, title TEXT , rating INTEGER ); - -- 'book_authors' is a many-to-many join table between books & authors - CREATE TABLE book_authors ( + -- 'book_author' is a many-to-many join table between books & authors + CREATE TABLE book_author ( book_id INTEGER, author_id INTEGER, PRIMARY KEY (book_id, author_id) ); - CREATE TABLE authors ( + CREATE TABLE author ( id INTEGER PRIMARY KEY, first_name TEXT, last_name TEXT @@ -578,27 +586,27 @@ C in your editor and enter: --- --- Load some sample data --- - INSERT INTO books VALUES (1, 'CCSP SNRS Exam Certification Guide', 5); - INSERT INTO books VALUES (2, 'TCP/IP Illustrated, Volume 1', 5); - INSERT INTO books VALUES (3, 'Internetworking with TCP/IP Vol.1', 4); - INSERT INTO books VALUES (4, 'Perl Cookbook', 5); - INSERT INTO books VALUES (5, 'Designing with Web Standards', 5); - INSERT INTO authors VALUES (1, 'Greg', 'Bastien'); - INSERT INTO authors VALUES (2, 'Sara', 'Nasseh'); - INSERT INTO authors VALUES (3, 'Christian', 'Degu'); - INSERT INTO authors VALUES (4, 'Richard', 'Stevens'); - INSERT INTO authors VALUES (5, 'Douglas', 'Comer'); - INSERT INTO authors VALUES (6, 'Tom', 'Christiansen'); - INSERT INTO authors VALUES (7, 'Nathan', 'Torkington'); - INSERT INTO authors VALUES (8, 'Jeffrey', 'Zeldman'); - INSERT INTO book_authors VALUES (1, 1); - INSERT INTO book_authors VALUES (1, 2); - INSERT INTO book_authors VALUES (1, 3); - INSERT INTO book_authors VALUES (2, 4); - INSERT INTO book_authors VALUES (3, 5); - INSERT INTO book_authors VALUES (4, 6); - INSERT INTO book_authors VALUES (4, 7); - INSERT INTO book_authors VALUES (5, 8); + INSERT INTO book VALUES (1, 'CCSP SNRS Exam Certification Guide', 5); + INSERT INTO book VALUES (2, 'TCP/IP Illustrated, Volume 1', 5); + INSERT INTO book VALUES (3, 'Internetworking with TCP/IP Vol.1', 4); + INSERT INTO book VALUES (4, 'Perl Cookbook', 5); + INSERT INTO book VALUES (5, 'Designing with Web Standards', 5); + INSERT INTO author VALUES (1, 'Greg', 'Bastien'); + INSERT INTO author VALUES (2, 'Sara', 'Nasseh'); + INSERT INTO author VALUES (3, 'Christian', 'Degu'); + INSERT INTO author VALUES (4, 'Richard', 'Stevens'); + INSERT INTO author VALUES (5, 'Douglas', 'Comer'); + INSERT INTO author VALUES (6, 'Tom', 'Christiansen'); + INSERT INTO author VALUES (7, 'Nathan', 'Torkington'); + INSERT INTO author VALUES (8, 'Jeffrey', 'Zeldman'); + INSERT INTO book_author VALUES (1, 1); + INSERT INTO book_author VALUES (1, 2); + INSERT INTO book_author VALUES (1, 3); + INSERT INTO book_author VALUES (2, 4); + INSERT INTO book_author VALUES (3, 5); + INSERT INTO book_author VALUES (4, 6); + INSERT INTO book_author VALUES (4, 7); + INSERT INTO book_author VALUES (5, 8); Then use the following command to build a C SQLite database: @@ -615,7 +623,7 @@ database contents: $ sqlite3 myapp.db SQLite version 3.5.9 Enter ".help" for instructions - sqlite> select * from books; + sqlite> select * from book; 1|CCSP SNRS Exam Certification Guide|5 2|TCP/IP Illustrated, Volume 1|5 3|Internetworking with TCP/IP Vol.1|4 @@ -626,7 +634,7 @@ database contents: Or: - $ sqlite3 myapp.db "select * from books" + $ sqlite3 myapp.db "select * from book" 1|CCSP SNRS Exam Certification Guide|5 2|TCP/IP Illustrated, Volume 1|5 3|Internetworking with TCP/IP Vol.1|4 @@ -639,6 +647,15 @@ required if you do a single SQL statement on the command line). Use ".q" to exit from SQLite from the SQLite interactive mode and return to your OS command prompt. +Please note that here we have chosen to use 'singular' table names. This +is because the default inflection code for L +does NOT handle plurals. There has been much philosophical discussion +on whether table names should be plural or singular. There is no one +correct answer, as long as one makes a choice and remains consistent +with it. If you prefer plural table names (e.g. they are easier and +more natural to read) then you will need to pass it an inflect_map +option. See L for more information. + For using other databases, such as PostgreSQL or MySQL, see L. @@ -675,6 +692,9 @@ running this command: 'print "$Catalyst::Model::DBIC::Schema::VERSION\n"' 0.23 +(please note that the '\' above is a line continuation marker and +should NOT be included as part of the command) + If you don't have version 0.23 or higher, please run this command to install it directly from CPAN: @@ -701,6 +721,9 @@ automatically build the required files for us: created "/home/me/MyApp/script/../lib/MyApp/Model/DB.pm" created "/home/me/MyApp/script/../t/model_DB.t" +(please note that the '\' above is a line continuation marker and +should NOT be included as part of the command) + The C