GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  CLASS::DBI::BASEDSN (3)

.ds Aq ’

NAME

Class::DBI::BaseDSN - DSN sensitive base class

CONTENTS

SYNOPSIS



  package My::DBI;
  use base Class::DBI::BaseDSN; # well decide later what our real
                                   # parent class will be
  __PACKAGE__->set_db( Main => $ENV{TESTING} ? @test_dsn : @real_dsn );



DESCRIPTION

Class::DBI::BaseDSN acts as a placeholder for a base class which will be switched for a specific Class::DBI extension when you specify the dsn of the database to connect to.

For example in this case, the Class::DBI::BaseDSN will replace itself with Class::DBI::mysql when the set_db call is executed.



 package Example::DBI;
 use base Class::DBI::BaseDSN;
 __PACKAGE__->set_db( Main => dbi:mysql:example, user, pass );



Since this happens at runtime you could pass the dsn as a variable and so have it use a completely different extension automatically. This is especially useful for testing, or for applications where dsn may be a configuration option.

If there is no matching extension found, Class::DBI::BaseDSN replaces itself with Class::DBI.

AUTHOR

Richard Clamp <richardc@unixbeard.net>

THANKS

Thanks go to Michael Schwern for a snippet to fake out caller, and for hashing out some of the finer points of the approach on the cdbi-talk list.

SEE ALSO

Class::DBI
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 CLASS::DBI::BASEDSN (3) 2016-03-17

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.