X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FManual%2FIntro.pod;h=4625d06da5d3af17fa0ca53451291b12b40b6750;hb=8d5a66b88fb9a4670fa09380621f4483f011d591;hp=dd37d0e8d3eb8f0d20d0b37e9fcb1086300dd08a;hpb=4ae94ded4219c6cb4231f8db5ffe121faa114782;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Manual/Intro.pod b/lib/DBIx/Class/Manual/Intro.pod index dd37d0e..4625d06 100644 --- a/lib/DBIx/Class/Manual/Intro.pod +++ b/lib/DBIx/Class/Manual/Intro.pod @@ -105,13 +105,14 @@ required resultset classes. Next, create each of the classes you want to load as specified above: package My::Schema::Result::Album; - use base qw/DBIx::Class/; + use base qw/DBIx::Class::Core/; -Load any components required by each class with the load_components() method. -This should consist of "Core" plus any additional components you want to use. -For example, if you want to force columns to use UTF-8 encoding: +Load any additional components you may need with the load_components() method, +and provide component configuration if required. For example, if you want +automatic row ordering: - __PACKAGE__->load_components(qw/ ForceUTF8 Core /); + __PACKAGE__->load_components(qw/ Ordered /); + __PACKAGE__->position_column('rank'); Set the table for your class: @@ -119,7 +120,7 @@ Set the table for your class: Add columns to your class: - __PACKAGE__->add_columns(qw/ albumid artist title /); + __PACKAGE__->add_columns(qw/ albumid artist title rank /); Each column can also be set up with its own accessor, data_type and other pieces of information that it may be useful to have -- just pass C a hash: @@ -145,13 +146,20 @@ of information that it may be useful to have -- just pass C a hash: is_nullable => 0, is_auto_increment => 0, default_value => '', + }, + rank => + { data_type => 'integer', + size => 16, + is_nullable => 0, + is_auto_increment => 0, + default_value => '', } ); DBIx::Class doesn't directly use most of this data yet, but various related modules such as L make use of it. Also it allows you to create your database tables from your Schema, instead of the other way around. -See L for details. +See L for details. See L for more details of the possible column attributes. @@ -200,8 +208,12 @@ many options. =head2 Connecting -To connect to your Schema, you need to provide the connection details. The -arguments are the same as for L: +To connect to your Schema, you need to provide the connection details or a +database handle. + +=head3 Via connection details + +The arguments are the same as for L: my $schema = My::Schema->connect('dbi:SQLite:/home/me/myapp/my.db'); @@ -227,6 +239,16 @@ a special fifth argument to connect: See L for more information about this and other special C-time options. +=head3 Via a database handle + +The supplied coderef is expected to return a single connected database handle +(e.g. a L C<$dbh>) + + my $schema = My::Schema->connect ( + sub { Some::DBH::Factory->connect }, + \%extra_attrs, + ); + =head2 Basic usage Once you've defined the basic classes, either manually or using @@ -253,8 +275,8 @@ instead: $album->set_column('title', 'Presence'); $title = $album->get_column('title'); -Just like with L, you call C to commit your changes to the -database: +Just like with L, you call C to save your changes to the +database (by executing the actual C statement): $album->update;