X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FManual%2FCookbook.pod;h=0cb560bdf9b9f84bf982e706e062f5d99a4b2060;hb=0488c7e1294791e01dc75dfe633454d0f4201384;hp=80ae5d08e160c64eaee8ef0f37884a0ffa90e70a;hpb=4a0eed52f392b2e135385d0c06b06160200f3772;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Manual/Cookbook.pod b/lib/DBIx/Class/Manual/Cookbook.pod index 80ae5d0..0cb560b 100644 --- a/lib/DBIx/Class/Manual/Cookbook.pod +++ b/lib/DBIx/Class/Manual/Cookbook.pod @@ -1163,14 +1163,14 @@ as each other and your connecting database user has the proper permissions to th To accomplish this one only needs to specify the DB schema name in the table declaration, like so... - package MyDatabase::Main::Artist; + package MyApp::Schema::Result::Artist; use base qw/DBIx::Class::Core/; __PACKAGE__->table('database1.artist'); # will use "database1.artist" in FROM clause __PACKAGE__->add_columns(qw/ artist_id name /); __PACKAGE__->set_primary_key('artist_id'); - __PACKAGE__->has_many('cds' => 'MyDatabase::Main::Cd'); + __PACKAGE__->has_many('cds' => 'MyApp::Schema::Result::Cd'); 1; @@ -1183,10 +1183,10 @@ of your application to support a change lifecycle (e.g. DEV, TEST, PROD) and the DB schemas are named based on the environment (e.g. database1_dev). However, one can dynamically "map" to the proper DB schema by overriding the -L method in your Schema class and +L method in your Schema class and building a renaming facility, like so: - package MyDatabase::Schema; + package MyApp::Schema; use Moose; extends 'DBIx::Class::Schema'; @@ -1223,16 +1223,16 @@ building a renaming facility, like so: 1; -By overriding the L +By overriding the L method and extracting a custom option from the provided \%attr hashref one can then simply iterate over all the Schema's ResultSources, renaming them as needed. To use this facility, simply add or modify the \%attr hashref that is passed to -L, as follows: +L, as follows: my $schema - = MyDatabase::Schema->connect( + = MyApp::Schema->connect( $dsn, $user, $pass,