SPOPS::Tool::DBI::Datasource - Embed the parameters for a DBI handle in object configuration


SPOPS documentation  | view source Contained in the SPOPS distribution.

Index


NAME

Top

SPOPS::Tool::DBI::Datasource -- Embed the parameters for a DBI handle in object configuration

SYNOPSIS

Top

 my $spops = {
   myobject => {
     class      => 'My::Object',
     rules_from => [ 'SPOPS::Tool::DBI::Datasource' ],
     dbi_config => { dsn => 'DBI:mysql:test',
                     username => 'kool',
                     password => 'andthegang' },
     ...
   },
 };
 SPOPS::Initialize->process({ config => $spops });
 my $object = My::Object->fetch( 'celebrate' );

DESCRIPTION

Top

This rule allows you to embed the DBI connection information in your object rather than using the strategies described elsewhere. This is very handy for creating simple, one-off scripts, but you should still use the subclassing strategy from SPOPS::Manual::Cookbook (SPOPS::Manual::Cookbook) if you will have multiple objects using the same datasource.

You can specify the following items in the configuration:

METHODS

Top

behavior_factory( $class )

Generates a behavior to generate the datasource retrieval code during the 'manipulate_configuration' phase.

datasource_access( $class )

Generates the 'global_datasource_handle()' method that retrieves an opened database handle if it exists or creates one otherwise.

BUGS

Top

None known.

TO DO

Top

Nothing known.

SEE ALSO

Top

SPOPS::Manual::CodeGeneration (SPOPS::Manual::CodeGeneration)

SPOPS::DBI

COPYRIGHT

Top

AUTHORS

Top

Chris Winters <chris@cwinters.com>

Thanks to jeffa on PerlMonks (http://www.perlmonks.org/index.pl?node_id=18800) for suggesting this!


SPOPS documentation  | view source Contained in the SPOPS distribution.