From: Kennedy Clark Date: Sat, 2 May 2009 01:12:46 +0000 (+0000) Subject: Remove DBIC "create=dynamic" section. Hopefully someone will proofread this for... X-Git-Tag: v5.8005~164 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Manual.git;a=commitdiff_plain;h=27909ed4d7378362d7a4f0eb87cb4abfc15db063 Remove DBIC "create=dynamic" section. Hopefully someone will proofread this for typos. --- diff --git a/lib/Catalyst/Manual/Tutorial/MoreCatalystBasics.pod b/lib/Catalyst/Manual/Tutorial/MoreCatalystBasics.pod index c2edcbe..553eed9 100644 --- a/lib/Catalyst/Manual/Tutorial/MoreCatalystBasics.pod +++ b/lib/Catalyst/Manual/Tutorial/MoreCatalystBasics.pod @@ -644,33 +644,160 @@ L. =head1 DATABASE ACCESS WITH DBIx::Class -Catalyst can be used with virtually any form of datastore available via -Perl. For example, L can be -used to access databases through the traditional Perl C -interface. However, most Catalyst applications use some form of -object-relational mapping (ORM) technology to create objects associated -with tables in a relational database. Although L -has been a popular choice in the past, Matt Trout's -L (abbreviated as "DBIC") has rapidly emerged -as the Perl-based ORM technology of choice. Most new Catalyst +Catalyst can be used with virtually any form of datastore available +via Perl. For example, L +can be used to access databases through the traditional Perl C +interface or you can use a model to access files of any type on the +filesystem. However, most Catalyst applications use some form of +object-relational mapping (ORM) technology to create objects +associated with tables in a relational database. Matt Trout's +L (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. +Although DBIC has included support for a C mode to +automatically read the database structure every time the application +starts, it's use is no longer recommended. While it can make +for "flashy" demos, the use of the C mode we use below +can be implemented just as quickly and provides many advantages (such +as the ability to add your own methods to the overall DBIC framework, +a technique that we see in Chapter 4). -=head2 Create a Dynamic DBIC Model -Use the C model helper option to build a model that -dynamically reads your database structure every time the application -starts: +=head2 Make Sure You Have a Recent Version of the DBIC Model + +First, let's be sure we have a recent version of the DBIC helper, +L, by +running this command: + + $ perl -MCatalyst::Model::DBIC::Schema -e \ + 'print "$Catalyst::Model::DBIC::Schema::VERSION\n"' + 0.23 + +If you don't have version 0.23 or higher, please run this command +to install it directly from CPAN: + + $ sudo cpan Catalyst::Model::DBIC::Schema + +And re-run the version print command to verify that you are now at +0.23 or higher. + + +=head2 Create Static DBIC Schema Files + +Use the model helper with the C option to read the +database with +L and +automatically build the required files for us: $ script/myapp_create.pl model DB DBIC::Schema MyApp::Schema \ - create=dynamic dbi:SQLite:myapp.db + create=static components=TimeStamp dbi:SQLite:myapp.db exists "/home/me/MyApp/script/../lib/MyApp/Model" exists "/home/me/MyApp/script/../t" - exists "/home/me/MyApp/script/../lib/MyApp" - created "/home/me/MyApp/script/../lib/MyApp/Schema.pm" + Dumping manual schema for MyApp::Schema to directory /home/me/MyApp/script/../lib ... + Schema dump completed. created "/home/me/MyApp/script/../lib/MyApp/Model/DB.pm" created "/home/me/MyApp/script/../t/model_DB.t" +The C