blib/lib/Lemonldap/NG/Common/Conf/Backends/RDBI.pm

filter: Statementstmt 80.0% 44 / 55 Branchbran 54.5% 12 / 22 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 85.7% 6 / 7 Podpod 0.0% 0 / 2 totaltotal 72.0% 62 / 86 CC 12 SCAR 17.8
CC
12
Cov
73%
store
8.7
load
6.7
_delete
2.0
CRAP 5.9
« blib/lib/Lemonldap/NG/Common/JWT.pm ↑ Summary blib/lib/Lemonldap/NG/Common/TOTP.pm »
1 package Lemonldap::NG::Common::Conf::Backends::RDBI;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Lemonldap::NG::Common::Conf::Serializer;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Lemonldap::NG::Common::Conf::Backends::_DBI;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 our $VERSION = '2.0.12';
9 1 our @ISA = qw(Lemonldap::NG::Common::Conf::Backends::_DBI);
10  
11 3 ▶sub store {
Subroutine store: called CC=7 SCAR=21.6
Pod undocumented
12 3 my ( $self, $fields ) = @_;
13 3 my $cfgNum = $fields->{cfgNum};
14 3 $self->{noQuotes} = 1;
15 3 $fields = $self->serialize($fields);
16  
17 3 my $req;
18 3 my $lastCfg = $self->lastCfg;
19 3 $self->_dbh->begin_work;
20 3 $req = $self->_dbh->prepare(
21 "INSERT INTO $self->{dbiTable} (cfgNum,field,value) VALUES (?,?,?)");
22  
23 3 ▶ _delete( $self, $cfgNum ) if $lastCfg == $cfgNum;
Branch: 1 branch
BranchTrueFalseTotal
if $lastCfg == $cfgNum 0 3 3
24 3 ▶ unless ($req) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($req) 0 3 3
25 0 $self->logError;
26 0 return UNKNOWN_ERROR;
27 }
28 3 ▶ while ( my ( $k, $v ) = each %$fields ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$fields) 6 3 9
29 6 my @execValues = ( $cfgNum, $k, $v );
30 6 my $execute;
31 6 eval { $execute = $req->execute(@execValues); };
32 6 ▶ print STDERR $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 6 6
33 6 ▶ unless ($execute) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($execute) 0 6 6
34 0 $self->logError;
35 0 ▶ _delete( $self, $cfgNum ) if $lastCfg != $cfgNum;
Branch: 1 branch
BranchTrueFalseTotal
if $lastCfg != $cfgNum 0 0 0
36 0 $self->_dbh->rollback;
37 0 return UNKNOWN_ERROR;
38 }
39 }
40 3 $self->_dbh->commit;
41 3 return $cfgNum;
42 }
43  
44 3 ▶sub load {
Subroutine load: called CC=6 SCAR=19.1
Pod undocumented
45 3 my ( $self, $cfgNum, $fields ) = @_;
46 3 ▶ $fields = $fields ? join( ",", @$fields ) : '*';
Branch: 1 branch
BranchTrueFalseTotal
$fields ? : 0 3 3
47 my $sth =
48 $self->_dbh->prepare(
49 3 ▶ "SELECT field,value from " . $self->{dbiTable} . " WHERE cfgNum=?" )
Branch: 1 branch
BranchTrueFalseTotal
my $sth = $self->_dbh->prepare('SELECT field,value from ' . $self->{"dbiTable"} . ' WHERE cfgNum=?') or $self->logError 3 0 3
50 or $self->logError;
51 3 ▶ $sth->execute($cfgNum) or $self->logError;
Branch: 1 branch
BranchTrueFalseTotal
$sth->execute($cfgNum) or $self->logError 3 0 3
52 3 my ( $res, @row );
53 3 ▶ while ( @row = $sth->fetchrow_array ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@row = $sth->fetchrow_array) 6 3 9
54 6 $res->{ $row[0] } = $row[1];
55 }
56 3 ▶ unless ($res) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($res) 0 3 3
57 0 $Lemonldap::NG::Common::Conf::msg .=
58 "No configuration $cfgNum found \n";
59 0 return 0;
60 }
61 3 $res->{cfgNum} = $cfgNum;
62 3 return $self->unserialize($res);
63 }
64  
65 0 ▶sub _delete {
Subroutine _delete: not called CC=1 SCAR=6.9
66 0 my ( $self, $cfgNum ) = @_;
67 0 my $r =
68 $self->_dbh->prepare("DELETE FROM $self->{dbiTable} where cfgNum=?");
69 0 $r->execute($cfgNum);
70 }
71  
72 1 1;
« blib/lib/Lemonldap/NG/Common/JWT.pm ↑ Summary blib/lib/Lemonldap/NG/Common/TOTP.pm »