File Coverage

blib/lib/Lemonldap/NG/Common/Conf/DBI.pm
Criterion Covered Total %
statement 9 26 34.6
branch 0 8 0.0
condition n/a
subroutine 3 5 60.0
pod 0 2 0.0
total 12 41 29.2


line stmt bran cond sub pod time code
1             package Lemonldap::NG::Common::Conf::DBI;
2              
3 1     1   7 use strict;
  1         3  
  1         48  
4 1     1   515 use Lemonldap::NG::Common::Conf::Serializer;
  1         4  
  1         47  
5 1     1   649 use Lemonldap::NG::Common::Conf::_DBI;
  1         4  
  1         486  
6              
7             our $VERSION = '1.4.0';
8             our @ISA = qw(Lemonldap::NG::Common::Conf::_DBI);
9              
10             sub store {
11 0     0 0   my ( $self, $fields ) = @_;
12 0 0         return DEPRECATED unless ( $self->{forceUpload} );
13 0           $fields = $self->serialize($fields);
14 0           my $tmp =
15             $self->_dbh->do( "insert into "
16             . $self->{dbiTable} . " ("
17             . join( ",", keys(%$fields) )
18             . ") values ("
19             . join( ",", values(%$fields) )
20             . ")" );
21 0 0         unless ($tmp) {
22 0           $self->logError;
23 0           return UNKNOWN_ERROR;
24             }
25 0           eval { $self->dbh->do("COMMIT"); };
  0            
26 0           return $fields->{cfgNum};
27             }
28              
29             sub load {
30 0     0 0   my ( $self, $cfgNum, $fields ) = @_;
31 0 0         $fields = $fields ? join( ",", @$fields ) : '*';
32 0           my $row = $self->_dbh->selectrow_hashref(
33             "SELECT $fields from " . $self->{dbiTable} . " WHERE cfgNum=?",
34             {}, $cfgNum );
35 0 0         unless ($row) {
36 0           $self->logError;
37 0           return 0;
38             }
39 0           return $self->unserialize($row);
40             }
41              
42             1;
43             __END__