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