From: Will Hawes Date: Sat, 21 Jan 2006 21:05:26 +0000 (+0000) Subject: update synopis/description X-Git-Tag: v0.05005~117^2~21 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a3d931943f65be6b19d1ab743e60d8344a680676;p=dbsrgits%2FDBIx-Class.git update synopis/description --- diff --git a/lib/DBIx/Class/Schema.pm b/lib/DBIx/Class/Schema.pm index ba03d01..1b55afa 100644 --- a/lib/DBIx/Class/Schema.pm +++ b/lib/DBIx/Class/Schema.pm @@ -20,40 +20,35 @@ DBIx::Class::Schema - composable schemas =head1 SYNOPSIS -in My/Schema.pm - package My::Schema; - use base qw/DBIx::Class::Schema/; - + + # load My::Schema::Foo, My::Schema::Bar, My::Schema::Baz __PACKAGE__->load_classes(qw/Foo Bar Baz/); -in My/Schema/Foo.pm - package My::Schema::Foo; - use base qw/DBIx::Class/; - __PACKAGE__->load_components(qw/PK::Auto::Pg Core/); # for example __PACKAGE__->table('foo'); - ... - -in My/DB.pm - - use My::Schema; - My::Schema->compose_connection('My::DB', $dsn, $user, $pass, $attrs); + my $schema1 = My::Schema->connect( + $dsn, + $user, + $password, + $attrs + ); -then in app code + my $schema2 = My::Schema->connect( ... ); - my @obj = My::DB::Foo->search({}); # My::DB::Foo isa My::Schema::Foo My::DB + # fetch objects using My::Schema::Foo + my $resultset = $schema1->resultset('Foo')->search( ... ); + my @objects = $schema2->resultset('Foo')->search( ... ); =head1 DESCRIPTION -Creates database classes based on a schema. This allows you to have more than -one concurrent connection using the same database classes, by making -subclasses under a new namespace for each connection. If you only need one -class, you should probably use L directly instead. +Creates database classes based on a schema. This is the recommended way to +use L and allows you to use more than one concurrent connection +with your classes. NB: If you're used to L it's worth reading the L carefully as DBIx::Class does things a little differently. Note in