line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DBIx::Handler::Sunny; |
2
|
1
|
|
|
1
|
|
687
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
56
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# cpan |
8
|
1
|
|
|
1
|
|
361
|
use parent qw(DBIx::Handler); |
|
1
|
|
|
|
|
259
|
|
|
1
|
|
|
|
|
4
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub _do_selectrow { # see DBI::_do_selectrow |
11
|
0
|
|
|
0
|
|
|
my ($self, $method, @args) = @_; |
12
|
0
|
0
|
|
|
|
|
my $sth = $self->query(@args) |
13
|
|
|
|
|
|
|
or return undef; |
14
|
0
|
0
|
|
|
|
|
my $row = $sth->$method() |
15
|
|
|
|
|
|
|
and $sth->finish; |
16
|
0
|
|
|
|
|
|
return $row; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub select_one { |
20
|
0
|
|
|
0
|
1
|
|
my ($self, @args) = @_; |
21
|
0
|
|
|
|
|
|
my $row = $self->_do_selectrow('fetchrow_arrayref', @args); |
22
|
0
|
0
|
|
|
|
|
return undef unless $row; |
23
|
0
|
|
|
|
|
|
return $row->[0]; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub select_row { |
27
|
0
|
|
|
0
|
1
|
|
my ($self, @args) = @_; |
28
|
0
|
|
|
|
|
|
my $row = $self->_do_selectrow('fetchrow_hashref', @args); |
29
|
0
|
0
|
|
|
|
|
return unless $row; |
30
|
0
|
|
|
|
|
|
return $row; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub select_all { |
34
|
0
|
|
|
0
|
1
|
|
my ($self, @args) = @_; |
35
|
0
|
0
|
|
|
|
|
my $sth = $self->query(@args) |
36
|
|
|
|
|
|
|
or return []; |
37
|
0
|
|
|
|
|
|
return $sth->fetchall_arrayref({}); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub last_insert_id { |
41
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
42
|
0
|
|
|
|
|
|
my $dsn = $self->{_connect_info}->[0]; |
43
|
0
|
0
|
|
|
|
|
if ($dsn =~ /^(?i:dbi):SQLite\b/) { |
|
|
0
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
return $self->dbh->func('last_insert_rowid'); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
elsif ( $dsn =~ /^(?i:dbi):mysql\b/) { |
47
|
0
|
|
|
|
|
|
return $self->dbh->{mysql_insertid}; |
48
|
|
|
|
|
|
|
} |
49
|
0
|
|
|
|
|
|
$self->dbh->last_insert_id(@_); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub txn { |
53
|
0
|
|
|
0
|
1
|
|
my ($self, $coderef) = @_; |
54
|
0
|
|
|
0
|
|
|
$self->SUPER::txn(sub { $coderef->($self) }); |
|
0
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |
58
|
|
|
|
|
|
|
__END__ |