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