1 package DBIx::Class::DB;
3 use base qw/Class::Data::Inheritable/;
6 __PACKAGE__->mk_classdata('_dbi_connect_info');
7 __PACKAGE__->mk_classdata('_dbi_connect_package');
8 __PACKAGE__->mk_classdata('_dbh');
12 DBIx::Class::DB - DBIx::Class Database connection
18 This class represents the connection to the database
29 unless (($dbh = $class->_dbh) && $dbh->FETCH('Active') && $dbh->ping) {
30 $class->_populate_dbh;
37 my @info = @{$class->_dbi_connect_info || []};
38 my $pkg = $class->_dbi_connect_package || $class;
39 $pkg->_dbh($class->_dbi_connect(@info));
43 my ($class, @info) = @_;
44 return DBI->connect(@info);
48 my ($class, @info) = @_;
49 $class->_dbi_connect_package($class);
50 $class->_dbi_connect_info(\@info);
53 sub dbi_commit { $_[0]->_get_dbh->commit; }
55 sub dbi_rollback { $_[0]->_get_dbh->rollback; }
63 Matt S. Trout <perl-stuff@trout.me.uk>
67 You may distribute this code under the same terms as Perl itself.