1 package DBIx::Class::DB;
3 use base qw/DBIx::Class/;
4 use DBIx::Class::Storage::DBI;
5 use DBIx::Class::ClassResolver::PassThrough;
10 DBIx::Class::DB - Simple DBIx::Class Database connection by class inheritance
16 use base qw/DBIx::Class/;
17 __PACKAGE__->load_components('DB');
19 __PACKAGE__->connection('dbi:...', 'user', 'pass', \%attrs);
21 package MyDB::MyTable;
24 __PACKAGE__->load_components('Core');
30 This class provides a simple way of specifying a database connection.
39 Which storage backend to be used. Defaults to L<DBIx::Class::Storage::DBI>
43 Which class to use for resolving a class. Defaults to
44 L<DBIx::Class::ClassResolver::Passthrough>, which returns whatever you throw
45 at it. See resolve_class below.
49 __PACKAGE__->mk_classdata('storage');
50 __PACKAGE__->mk_classdata('class_resolver' =>
51 'DBIx::Class::ClassResolver::PassThrough');
55 __PACKAGE__->connection($dsn, $user, $pass, $attrs);
57 Specifies the arguments that will be passed to DBI->connect(...) to
58 instantiate the class dbh when required.
63 my ($class, @info) = @_;
64 my $storage = DBIx::Class::Storage::DBI->new;
65 $storage->connect_info(\@info);
66 $class->storage($storage);
73 Issues a commit again the current dbh
77 sub dbi_commit { $_[0]->storage->commit; }
83 Issues a rollback again the current dbh
87 sub dbi_rollback { $_[0]->storage->rollback; }
89 sub resolve_class { return shift->class_resolver->class(@_); }
97 Matt S. Trout <mst@shadowcatsystems.co.uk>
101 You may distribute this code under the same terms as Perl itself.