1 package SGN
::Role
::Site
::DBIC
;
5 use namespace
::autoclean
;
9 use Class
::Load
':all';
13 'ensure_dbh_search_path_is_set',
19 Usage: my $schema = $c->dbic_schema( 'Schema::Package', 'connection_name' );
20 Desc : get a L<DBIx::Class::Schema> with the proper connection
21 parameters for the given connection name
22 Args : L<DBIx::Class> schema package name,
23 (optional) connection name to use
25 Side Effects: dies on failure
30 my ( $class, $schema_name, $profile_name ) = @_;
31 $class = ref $class if ref $class;
33 $schema_name or croak
"must provide a schema package name to dbic_schema";
34 #Class::MOP::load_class( $schema_name );
35 load_class
( $schema_name );
37 return $schema_cache{$class}{$profile_name || ''}{$schema_name} ||= do {
38 my $profile = $class->dbc_profile( $profile_name );
39 $schema_name->connect(
40 @
{$profile}{qw
| dsn user password attributes
|},
41 { on_connect_call
=> sub { $class->ensure_dbh_search_path_is_set( shift->dbh ) } },