| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Mojo::mysql::Transaction; |
|
2
|
18
|
|
|
18
|
|
110
|
use Mojo::Base -base; |
|
|
18
|
|
|
|
|
32
|
|
|
|
18
|
|
|
|
|
154
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
has 'db'; |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub DESTROY { |
|
7
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
8
|
0
|
0
|
0
|
|
|
|
if ($self->{rollback} && (my $dbh = $self->{dbh})) { $dbh->rollback } |
|
|
0
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
} |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub commit { |
|
12
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
13
|
0
|
0
|
|
|
|
|
$self->{dbh}->commit if delete $self->{rollback}; |
|
14
|
|
|
|
|
|
|
} |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new { |
|
17
|
0
|
|
|
0
|
1
|
|
my $self = shift->SUPER::new(@_, rollback => 1); |
|
18
|
0
|
|
|
|
|
|
$self->{dbh} = $self->db->dbh; |
|
19
|
0
|
|
|
|
|
|
$self->{dbh}->begin_work; |
|
20
|
0
|
|
|
|
|
|
return $self; |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
1; |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=encoding utf8 |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 NAME |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Mojo::mysql::Transaction - Transaction |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
use Mojo::mysql::Transaction; |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my $tx = Mojo::mysql::Transaction->new(db => $db); |
|
36
|
|
|
|
|
|
|
$tx->commit; |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
L is a cope guard for L transactions used by |
|
41
|
|
|
|
|
|
|
L. |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
L implements the following attributes. |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head2 db |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
my $db = $tx->db; |
|
50
|
|
|
|
|
|
|
$tx = $tx->db(Mojo::mysql::Database->new); |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
L object this transaction belongs to. |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 METHODS |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
L inherits all methods from L and |
|
57
|
|
|
|
|
|
|
implements the following new ones. |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 commit |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
$tx = $tx->commit; |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Commit transaction. |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head2 new |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
my $tx = Mojo::mysql::Transaction->new; |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Construct a new L object. |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
L. |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=cut |