_get_dbh removed
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / DB.pm
CommitLineData
ea2e61bf 1package DBIx::Class::DB;
2
3use base qw/Class::Data::Inheritable/;
8b445e33 4use DBIx::Class::Storage::DBI;
604d9f38 5use DBI;
ea2e61bf 6
34d52be2 7=head1 NAME
8
8b445e33 9DBIx::Class::DB - Simple DBIx::Class Database connection by class inheritance
34d52be2 10
11=head1 SYNOPSIS
12
8b445e33 13 package MyDB;
14
15 use base qw/DBIx::Class/;
16 __PACKAGE__->load_components('DB');
17
18 __PACKAGE__->connection('dbi:...', 'user', 'pass', \%attrs);
19
20 package MyDB::MyTable;
21
22 use base qw/MyDB/;
23 __PACKAGE__->load_components('Table');
24
34d52be2 25=head1 DESCRIPTION
26
8b445e33 27This class provides a simple way of specifying a database connection.
34d52be2 28
29=head1 METHODS
30
31=over 4
32
33=cut
34
8b445e33 35__PACKAGE__->mk_classdata('storage');
8fe001e1 36
39fe0e65 37=item connection
38
39 __PACKAGE__->connection($dsn, $user, $pass, $attrs);
40
41Specifies the arguments that will be passed to DBI->connect(...) to
42instantiate the class dbh when required.
43
44=cut
45
8fe001e1 46sub connection {
47 my ($class, @info) = @_;
8b445e33 48 my $storage = DBIx::Class::Storage::DBI->new;
49 $storage->connect_info(\@info);
50 $class->storage($storage);
ea2e61bf 51}
52
39fe0e65 53=item dbi_commit
54
55 $class->dbi_commit;
56
57Issues a commit again the current dbh
58
59=cut
60
8b445e33 61sub dbi_commit { $_[0]->storage->commit; }
a29644e1 62
39fe0e65 63=item dbi_rollback
64
65 $class->dbi_rollback;
66
67Issues a rollback again the current dbh
68
69=cut
70
8b445e33 71sub dbi_rollback { $_[0]->storage->rollback; }
72
ea2e61bf 731;
34d52be2 74
75=back
76
77=head1 AUTHORS
78
79Matt S. Trout <perl-stuff@trout.me.uk>
80
81=head1 LICENSE
82
83You may distribute this code under the same terms as Perl itself.
84
85=cut
86