Commit | Line | Data |
---|---|---|
843f8ecd | 1 | package DBIx::Class::Storage::DBI::mysql; |
2 | ||
3 | use strict; | |
4 | use warnings; | |
5 | ||
6 | use base qw/DBIx::Class::Storage::DBI/; | |
7 | ||
8 | # __PACKAGE__->load_components(qw/PK::Auto/); | |
9 | ||
d4f16b21 | 10 | sub _dbh_last_insert_id { |
11 | my ($self, $dbh, $source, $col) = @_; | |
12 | $dbh->{mysql_insertid}; | |
843f8ecd | 13 | } |
14 | ||
e8d293df | 15 | sub sqlt_type { |
16 | return 'MySQL'; | |
17 | } | |
18 | ||
adb3554a | 19 | sub _svp_begin { |
eeb8cfeb | 20 | my ($self, $name) = @_; |
adb3554a | 21 | |
eeb8cfeb | 22 | $self->dbh->do("SAVEPOINT $name"); |
adb3554a | 23 | } |
24 | ||
25 | sub _svp_release { | |
eeb8cfeb | 26 | my ($self, $name) = @_; |
adb3554a | 27 | |
eeb8cfeb | 28 | $self->dbh->do("RELEASE SAVEPOINT $name"); |
adb3554a | 29 | } |
30 | ||
31 | sub _svp_rollback { | |
eeb8cfeb | 32 | my ($self, $name) = @_; |
adb3554a | 33 | |
eeb8cfeb | 34 | $self->dbh->do("ROLLBACK TO SAVEPOINT $name") |
adb3554a | 35 | } |
f797e89e | 36 | |
106d5f3b | 37 | sub is_replicating { |
f797e89e | 38 | my $status = shift->dbh->selectrow_hashref('show slave status'); |
39 | return ($status->{Slave_IO_Running} eq 'Yes') && ($status->{Slave_SQL_Running} eq 'Yes'); | |
106d5f3b | 40 | } |
41 | ||
42 | sub lag_behind_master { | |
f797e89e | 43 | return shift->dbh->selectrow_hashref('show slave status')->{Seconds_Behind_Master}; |
106d5f3b | 44 | } |
45 | ||
843f8ecd | 46 | 1; |
47 | ||
75d07914 | 48 | =head1 NAME |
843f8ecd | 49 | |
50 | DBIx::Class::Storage::DBI::mysql - Automatic primary key class for MySQL | |
51 | ||
52 | =head1 SYNOPSIS | |
53 | ||
54 | # In your table classes | |
55 | __PACKAGE__->load_components(qw/PK::Auto Core/); | |
56 | __PACKAGE__->set_primary_key('id'); | |
57 | ||
58 | =head1 DESCRIPTION | |
59 | ||
60 | This class implements autoincrements for MySQL. | |
61 | ||
62 | =head1 AUTHORS | |
63 | ||
64 | Matt S. Trout <mst@shadowcatsystems.co.uk> | |
65 | ||
66 | =head1 LICENSE | |
67 | ||
68 | You may distribute this code under the same terms as Perl itself. | |
69 | ||
70 | =cut |