1 package DBIx::Class::DB;
3 use base qw/Class::Data::Inheritable/;
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('Core');
19 __PACKAGE__->connection('dbi:...', 'user', 'pass', \%attrs);
21 package MyDB::MyTable;
29 This class provides a simple way of specifying a database connection.
37 __PACKAGE__->mk_classdata('storage');
38 __PACKAGE__->mk_classdata('class_resolver' =>
39 'DBIx::Class::ClassResolver::PassThrough');
43 __PACKAGE__->connection($dsn, $user, $pass, $attrs);
45 Specifies the arguments that will be passed to DBI->connect(...) to
46 instantiate the class dbh when required.
51 my ($class, @info) = @_;
52 my $storage = DBIx::Class::Storage::DBI->new;
53 $storage->connect_info(\@info);
54 $class->storage($storage);
61 Issues a commit again the current dbh
65 sub dbi_commit { $_[0]->storage->commit; }
71 Issues a rollback again the current dbh
75 sub dbi_rollback { $_[0]->storage->rollback; }
77 sub resolve_class { return shift->class_resolver->class(@_); }
85 Matt S. Trout <mst@shadowcatsystems.co.uk>
89 You may distribute this code under the same terms as Perl itself.