blib/lib/Lemonldap/NG/Common/Conf/Backends/DBI.pm untested

filter: Statementstmt 0.0% 0 / 32 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 48 CC 5 SCAR 20.8
CC
5
Cov
0%
store
12.0
load
12.0
BEGIN
2.0
CRAP 8.0
1 package Lemonldap::NG::Common::Conf::Backends::DBI;
2  
3 use strict;
4 use utf8;
5 use Lemonldap::NG::Common::Conf::Serializer;
6 use Lemonldap::NG::Common::Conf::Backends::_DBI;
7  
8 our $VERSION = '2.0.0';
9 our @ISA = qw(Lemonldap::NG::Common::Conf::Backends::_DBI);
10  
11 sub store {
12 my ( $self, $fields ) = @_;
13 return DEPRECATED unless ( $self->{forceUpload} );
14 $fields = $self->serialize($fields);
15 my $tmp =
16 $self->_dbh->do( "insert into "
17 . $self->{dbiTable} . " ("
18 . join( ",", keys(%$fields) )
19 . ") values ("
20 . join( ",", values(%$fields) )
21 . ")" );
22 unless ($tmp) {
23 $self->logError;
24 return UNKNOWN_ERROR;
25 }
26 eval { $self->dbh->do("COMMIT"); };
27 return $fields->{cfgNum};
28 }
29  
30 sub load {
31 my ( $self, $cfgNum, $fields ) = @_;
32 $fields = $fields ? join( ",", @$fields ) : '*';
33 my $row = $self->_dbh->selectrow_hashref(
34 "SELECT $fields from " . $self->{dbiTable} . " WHERE cfgNum=?",
35 {}, $cfgNum );
36 unless ($row) {
37 $self->logError;
38 return 0;
39 }
40 return $self->unserialize($row);
41 }
42  
43 1;
44 __END__