1 package DBIx::Class::DB;
3 use base qw/DBIx::Class/;
4 use DBIx::Class::Storage::DBI;
5 use DBIx::Class::ClassResolver::PassThrough;
8 *dbi_commit = \&txn_commit;
9 *dbi_rollback = \&txn_rollback;
13 DBIx::Class::DB - Simple DBIx::Class Database connection by class inheritance
19 use base qw/DBIx::Class/;
20 __PACKAGE__->load_components('DB');
22 __PACKAGE__->connection('dbi:...', 'user', 'pass', \%attrs);
24 package MyDB::MyTable;
27 __PACKAGE__->load_components('Core'); # just load this in MyDB if it will always be there
33 This class provides a simple way of specifying a database connection.
39 Sets or gets the storage backend. Defaults to L<DBIx::Class::Storage::DBI>.
43 Sets or gets the class to use for resolving a class. Defaults to
44 L<DBIx::Class::ClassResolver::Passthrough>, which returns whatever you give
45 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);
71 Begins a transaction (does nothing if AutoCommit is off).
75 sub txn_begin { $_[0]->storage->txn_begin }
79 Commits the current transaction.
83 sub txn_commit { $_[0]->storage->txn_commit }
87 Rolls back the current transaction.
91 sub txn_rollback { $_[0]->storage->txn_rollback }
93 sub resolve_class { return shift->class_resolver->class(@_); }
99 Matt S. Trout <mst@shadowcatsystems.co.uk>
103 You may distribute this code under the same terms as Perl itself.