Get a database handle

From ClassDBI

Revision as of 16:52, 17 December 2008 by EdwardSabol (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search

How do you get a $dbh from your CDBI object?

In your script:

 my $dbi = $class->db_Main()

or in your class file

 my $dbi = __PACKAGE__->db_Main()

Class::DBI inherits from Ima::DBI; Ima::DBI creates the "db_Main" method when Class::DBI::connection() calls Ima::DBI's set_db().

Since Class::DBI explicitly names the connection "Main", the method is called "db_Main".