From: Brandon L. Black Date: Tue, 11 Jul 2006 00:32:33 +0000 (+0000) Subject: Intro updates regarding Schema::Loader usage and on_connect_do X-Git-Tag: v0.07002~75^2~30 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3f073ddff92999c67b2e68af9d5ece580c66bffd;p=dbsrgits%2FDBIx-Class.git Intro updates regarding Schema::Loader usage and on_connect_do --- diff --git a/lib/DBIx/Class/Manual/Intro.pod b/lib/DBIx/Class/Manual/Intro.pod index 62b0fd2..43e60cf 100644 --- a/lib/DBIx/Class/Manual/Intro.pod +++ b/lib/DBIx/Class/Manual/Intro.pod @@ -184,7 +184,6 @@ that contain this tables foreign key in one of their columns: More information about the various types of relationships available, and how you can design your own, can be found in L. - =head2 Using L This is an external module, and not part of the L @@ -195,26 +194,20 @@ Here's a simple setup: package My::Schema; use base qw/DBIx::Class::Schema::Loader/; - __PACKAGE__->load_from_connection( - connect_info = [ 'dbi:SQLite:/home/me/myapp/my.db' ] - ); + __PACKAGE__->loader_options( relationships => 1 ); 1; -This should be equivalent to the manual setup in the section above. +The actual autoloading process will occur when you create a connected +instance of your schema below. + L takes lots of other options. For more information, consult its documentation. =head2 Connecting -L already contains the connection info for the -database, so to get started all you need to do is create an instance of your -class: - - my $schema = My::Schema->new(); - -To connect to your manually created Schema, you also need to provide the -connection details: +To connect to your Schema, you also need to provide the connection details. +The arguments are the same as you would use for L: my $schema = My::Schema->connect('dbi:SQLite:/home/me/myapp/my.db'); @@ -226,9 +219,19 @@ a second database you want to access: Note that L does not cache connections for you. If you use multiple connections, you need to do this manually. -To execute some sql statements on every connect you can pass them to your schema after the connect: +To execute some sql statements on every connect you can add them as an option +in a special fifth argument to connect, like so: + + my $another_schema = My::Schema->connect( + $dsn, + $user, + $password, + $attrs, + { on_connect_do => \@on_connect_sql_statments } + ); - $schema->storage->on_connect_do(\@on_connect_sql_statments); +For more information about this and other special C-time options, +see L. =head2 Basic usage