File Coverage

blib/lib/DBIx/Handler/Sunny.pm
Criterion Covered Total %
statement 9 30 30.0
branch 0 14 0.0
condition n/a
subroutine 3 8 37.5
pod 4 4 100.0
total 16 56 28.5


line stmt bran cond sub pod time code
1             package DBIx::Handler::Sunny;
2 1     1   620 use strict;
  1         2  
  1         34  
3 1     1   4 use warnings;
  1         1  
  1         50  
4              
5             our $VERSION = '0.01';
6              
7             # cpan
8 1     1   436 use parent qw(DBIx::Handler);
  1         276  
  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             1;
53             __END__