| 1 | package SQLayer; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 1 | $SQLayer::VERSION = '1.1'; | |||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 1 | ▶ | use Carp; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 1 | ▶ | use DBI; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | sub new | ||||||||||||||||||||
| 10 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 11 | 0 | my ($class, %HKeys) = @_; | |||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | 0 | my $self = {DEBUG => '', | |||||||||||||||||||
| 14 | errstr => ''}; | ||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | 0 | bless $self, $class; | |||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | 0 | $self -> _init(%HKeys); | |||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | 0 | return $self | |||||||||||||||||||
| 21 | } | ||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | sub DESTROY | ||||||||||||||||||||
| 24 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 25 | 0 | shift -> {dbh} -> disconnect; | |||||||||||||||||||
| 26 | } | ||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | sub errstr | ||||||||||||||||||||
| 29 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
errstr: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | return shift -> {errstr} | ||||||||||||||||||||
| 32 | 0 | } | |||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | sub DEBUG | ||||||||||||||||||||
| 35 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
DEBUG: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||
| 36 | 0 | my $self = shift; | |||||||||||||||||||
| 37 | 0 | my $level = shift; | |||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | 0 | ▶ | return $self -> {DEBUG} unless $level; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | 0 | ▶ | $self -> {DEBUG} = 1 if $level == 1; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | 0 | ▶ | DBI -> trace($level - 1) unless $level == 1; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | 0 | return 1 | |||||||||||||||||||
| 46 | } | ||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | sub transaction | ||||||||||||||||||||
| 49 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
transaction: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 50 | 0 | my $self = shift; | |||||||||||||||||||
| 51 | 0 | ▶ | if ($self -> {'TRANSACTION'} ne 'YES') | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 52 | { | ||||||||||||||||||||
| 53 | 0 | $self -> enable_transactions(); | |||||||||||||||||||
| 54 | 0 | $self -> proc("BEGIN"); | |||||||||||||||||||
| 55 | 0 | $self -> {'TRANSACTION'} = 'YES'; | |||||||||||||||||||
| 56 | 0 | } else { warn "SQLayer: Transaction already in progress!" } | |||||||||||||||||||
| 57 | } | ||||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | sub commit | ||||||||||||||||||||
| 61 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
commit: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 62 | 0 | my $self = shift; | |||||||||||||||||||
| 63 | 0 | ▶ | if ($self -> {'TRANSACTION'} eq 'YES') | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 64 | { | ||||||||||||||||||||
| 65 | 0 | my $dbh = $self -> {'dbh'}; | |||||||||||||||||||
| 66 | 0 | $dbh -> commit(); | |||||||||||||||||||
| 67 | 0 | $self -> disable_transactions(); | |||||||||||||||||||
| 68 | 0 | $self -> {'TRANSACTION'} = 'NO'; | |||||||||||||||||||
| 69 | 0 | } else { warn "SQLayer: No transaction in progress or method 'begin' never called. Please use methob 'begin' to handle transactions!" } | |||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | } | ||||||||||||||||||||
| 72 | |||||||||||||||||||||
| 73 | sub rollback | ||||||||||||||||||||
| 74 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
rollback: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 75 | 0 | my $self = shift; | |||||||||||||||||||
| 76 | 0 | ▶ | if ($self -> {'TRANSACTION'} eq 'YES') | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 77 | { | ||||||||||||||||||||
| 78 | 0 | my $dbh = $self -> {'dbh'}; | |||||||||||||||||||
| 79 | 0 | $dbh -> rollback(); | |||||||||||||||||||
| 80 | 0 | $self -> disable_transactions(); | |||||||||||||||||||
| 81 | 0 | $self -> {'TRANSACTION'} = 'NO'; | |||||||||||||||||||
| 82 | 0 | } else { warn "SQLayer: No transaction in progress or method 'begin' never called. Please use methob 'begin' to handle transactions!" } | |||||||||||||||||||
| 83 | } | ||||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | sub enable_transactions | ||||||||||||||||||||
| 86 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
enable_transactions: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 87 | 0 | my $self = shift; | |||||||||||||||||||
| 88 | |||||||||||||||||||||
| 89 | 0 | my $dbh = $self -> {'dbh'}; | |||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | 0 | $dbh->{'AutoCommit'} = 0; # enable transactions, if possible | |||||||||||||||||||
| 92 | 0 | $dbh->{'RaiseError'} = 1 | |||||||||||||||||||
| 93 | } | ||||||||||||||||||||
| 94 | |||||||||||||||||||||
| 95 | sub disable_transactions | ||||||||||||||||||||
| 96 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
disable_transactions: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 97 | 0 | my $self = shift; | |||||||||||||||||||
| 98 | |||||||||||||||||||||
| 99 | 0 | my $dbh = $self -> {'dbh'}; | |||||||||||||||||||
| 100 | |||||||||||||||||||||
| 101 | 0 | $dbh->{'AutoCommit'} = 1; # enable transactions, if possible | |||||||||||||||||||
| 102 | 0 | $dbh->{'RaiseError'} = 1 | |||||||||||||||||||
| 103 | } | ||||||||||||||||||||
| 104 | sub connect_status | ||||||||||||||||||||
| 105 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
connect_status: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 106 | |||||||||||||||||||||
| 107 | return shift -> {connect_status} | ||||||||||||||||||||
| 108 | 0 | } | |||||||||||||||||||
| 109 | |||||||||||||||||||||
| 110 | sub nodebug | ||||||||||||||||||||
| 111 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
nodebug: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 112 | 0 | shift -> {DEBUG} = '' | |||||||||||||||||||
| 113 | } | ||||||||||||||||||||
| 114 | |||||||||||||||||||||
| 115 | sub row | ||||||||||||||||||||
| 116 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
row: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||
| 117 | 0 | my $self = shift; | |||||||||||||||||||
| 118 | 0 | my $query = shift; | |||||||||||||||||||
| 119 | |||||||||||||||||||||
| 120 | 0 | ▶ | warn $query if $self -> DEBUG; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 121 | |||||||||||||||||||||
| 122 | 0 | my $sth; | |||||||||||||||||||
| 123 | 0 | my $dbh = $self -> {'dbh'}; | |||||||||||||||||||
| 124 | |||||||||||||||||||||
| 125 | eval | ||||||||||||||||||||
| 126 | 0 | { | |||||||||||||||||||
| 127 | $sth = $dbh -> prepare($query) || do | ||||||||||||||||||||
| 128 | 0 | ▶ | { | ||||||||||||||||||
|
Condition0%0/3
$dbh->prepare($query) || do {
warn $dbh->errstr, " $query\n";
$self->{'errstr'} .= $dbh->errstr;
return undef
}
MC/DC0%0/2
$dbh->prepare($query) || do {
warn $dbh->errstr, " $query\n";
$self->{'errstr'} .= $dbh->errstr;
return undef
}
$dbh->prepare($query)
do {
warn $dbh->errstr, " $query\n";
$self->{'errstr'} .= $dbh->errstr;
return undef
}
Truth table0%0/3
A || B
A= $dbh->prepare($query)B= do {
warn $dbh->errstr, " $query\n";
$self->{'errstr'} .= $dbh->errstr;
return undef
}
| |||||||||||||||||||||
| 129 | 0 | warn $dbh -> errstr, " $query\n"; | |||||||||||||||||||
| 130 | 0 | $self -> {errstr} .= $dbh->errstr; | |||||||||||||||||||
| 131 | 0 | return undef; | |||||||||||||||||||
| 132 | }; | ||||||||||||||||||||
| 133 | }; | ||||||||||||||||||||
| 134 | |||||||||||||||||||||
| 135 | eval | ||||||||||||||||||||
| 136 | 0 | { | |||||||||||||||||||
| 137 | $sth -> execute || do | ||||||||||||||||||||
| 138 | 0 | ▶ | { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 139 | 0 | warn $dbh -> errstr, " $query\n"; | |||||||||||||||||||
| 140 | 0 | $self -> {errstr} .= $dbh -> errstr; | |||||||||||||||||||
| 141 | 0 | return undef; | |||||||||||||||||||
| 142 | }; | ||||||||||||||||||||
| 143 | }; | ||||||||||||||||||||
| 144 | |||||||||||||||||||||
| 145 | 0 | my @row = $sth -> fetchrow_array; | |||||||||||||||||||
| 146 | |||||||||||||||||||||
| 147 | 0 | $sth -> finish; | |||||||||||||||||||
| 148 | |||||||||||||||||||||
| 149 | 0 | ▶ | return wantarray ? @row : $row[0]; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 150 | } | ||||||||||||||||||||
| 151 | |||||||||||||||||||||
| 152 | sub proc | ||||||||||||||||||||
| 153 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
proc: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||
| 154 | 0 | my $self = shift; | |||||||||||||||||||
| 155 | 0 | my $query = shift; | |||||||||||||||||||
| 156 | |||||||||||||||||||||
| 157 | 0 | ▶ | warn $query if $self -> DEBUG; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 158 | |||||||||||||||||||||
| 159 | 0 | my $res = $self -> {'dbh'} -> do($query); | |||||||||||||||||||
| 160 | 0 | $self -> {errstr} .= $self -> {dbh} -> errstr; | |||||||||||||||||||
| 161 | |||||||||||||||||||||
| 162 | 0 | ▶ | return $res if $res; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 163 | |||||||||||||||||||||
| 164 | 0 | return undef; | |||||||||||||||||||
| 165 | } | ||||||||||||||||||||
| 166 | |||||||||||||||||||||
| 167 | sub all_rows | ||||||||||||||||||||
| 168 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
all_rows: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||
| 169 | 0 | my $self = shift; | |||||||||||||||||||
| 170 | 0 | my $query = shift; | |||||||||||||||||||
| 171 | |||||||||||||||||||||
| 172 | 0 | my $sth; | |||||||||||||||||||
| 173 | |||||||||||||||||||||
| 174 | 0 | ▶ | warn $query if $self -> DEBUG; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 175 | |||||||||||||||||||||
| 176 | 0 | my $dbh = $self -> {'dbh'}; | |||||||||||||||||||
| 177 | |||||||||||||||||||||
| 178 | eval | ||||||||||||||||||||
| 179 | 0 | { | |||||||||||||||||||
| 180 | $sth = $dbh -> prepare($query) || do | ||||||||||||||||||||
| 181 | 0 | ▶ | { | ||||||||||||||||||
|
Condition0%0/3
$dbh->prepare($query) || do {
warn $dbh->errstr, " $query\n";
$self->{'errstr'} .= $dbh->errstr;
return undef
}
MC/DC0%0/2
$dbh->prepare($query) || do {
warn $dbh->errstr, " $query\n";
$self->{'errstr'} .= $dbh->errstr;
return undef
}
$dbh->prepare($query)
do {
warn $dbh->errstr, " $query\n";
$self->{'errstr'} .= $dbh->errstr;
return undef
}
Truth table0%0/3
A || B
A= $dbh->prepare($query)B= do {
warn $dbh->errstr, " $query\n";
$self->{'errstr'} .= $dbh->errstr;
return undef
}
| |||||||||||||||||||||
| 182 | 0 | warn $dbh -> errstr, " $query\n"; | |||||||||||||||||||
| 183 | 0 | $self -> {errstr} .= $dbh -> errstr; | |||||||||||||||||||
| 184 | 0 | return undef; | |||||||||||||||||||
| 185 | } | ||||||||||||||||||||
| 186 | }; | ||||||||||||||||||||
| 187 | |||||||||||||||||||||
| 188 | eval | ||||||||||||||||||||
| 189 | 0 | { | |||||||||||||||||||
| 190 | $sth -> execute || do | ||||||||||||||||||||
| 191 | 0 | ▶ | { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 192 | 0 | warn $dbh -> errstr, " $query\n"; | |||||||||||||||||||
| 193 | 0 | $self -> {errstr} .= $dbh -> errstr; | |||||||||||||||||||
| 194 | 0 | return undef; | |||||||||||||||||||
| 195 | } | ||||||||||||||||||||
| 196 | }; | ||||||||||||||||||||
| 197 | |||||||||||||||||||||
| 198 | 0 | my $ret = $sth -> fetchall_arrayref; | |||||||||||||||||||
| 199 | 0 | $sth -> finish; | |||||||||||||||||||
| 200 | |||||||||||||||||||||
| 201 | 0 | return $ret; | |||||||||||||||||||
| 202 | } | ||||||||||||||||||||
| 203 | |||||||||||||||||||||
| 204 | sub row_hash | ||||||||||||||||||||
| 205 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
row_hash: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||
| 206 | 0 | my $self = shift; | |||||||||||||||||||
| 207 | 0 | my $query = shift; | |||||||||||||||||||
| 208 | |||||||||||||||||||||
| 209 | 0 | my $sth; | |||||||||||||||||||
| 210 | |||||||||||||||||||||
| 211 | 0 | ▶ | warn $query if $self->DEBUG; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 212 | |||||||||||||||||||||
| 213 | 0 | my $dbh = $self->{'dbh'}; | |||||||||||||||||||
| 214 | |||||||||||||||||||||
| 215 | eval | ||||||||||||||||||||
| 216 | 0 | { | |||||||||||||||||||
| 217 | $sth = $dbh->prepare($query) || do | ||||||||||||||||||||
| 218 | 0 | ▶ | { | ||||||||||||||||||
|
Condition0%0/3
$dbh->prepare($query) || do {
warn $dbh->errstr, " $query\n";
$self->{'errstr'} .= $dbh->errstr;
return undef
}
MC/DC0%0/2
$dbh->prepare($query) || do {
warn $dbh->errstr, " $query\n";
$self->{'errstr'} .= $dbh->errstr;
return undef
}
$dbh->prepare($query)
do {
warn $dbh->errstr, " $query\n";
$self->{'errstr'} .= $dbh->errstr;
return undef
}
Truth table0%0/3
A || B
A= $dbh->prepare($query)B= do {
warn $dbh->errstr, " $query\n";
$self->{'errstr'} .= $dbh->errstr;
return undef
}
| |||||||||||||||||||||
| 219 | 0 | warn $dbh->errstr, " $query\n"; | |||||||||||||||||||
| 220 | 0 | $self->{errstr} .= $dbh->errstr; | |||||||||||||||||||
| 221 | 0 | return undef; | |||||||||||||||||||
| 222 | } | ||||||||||||||||||||
| 223 | }; | ||||||||||||||||||||
| 224 | |||||||||||||||||||||
| 225 | eval | ||||||||||||||||||||
| 226 | 0 | { | |||||||||||||||||||
| 227 | $sth->execute || do | ||||||||||||||||||||
| 228 | 0 | ▶ | { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 229 | 0 | warn $dbh->errstr, " $query\n"; | |||||||||||||||||||
| 230 | 0 | $self->{errstr} .= $dbh->errstr; | |||||||||||||||||||
| 231 | 0 | return undef; | |||||||||||||||||||
| 232 | } | ||||||||||||||||||||
| 233 | }; | ||||||||||||||||||||
| 234 | |||||||||||||||||||||
| 235 | 0 | my $ret = $sth->fetchall_arrayref({}); | |||||||||||||||||||
| 236 | |||||||||||||||||||||
| 237 | 0 | $sth -> finish; | |||||||||||||||||||
| 238 | |||||||||||||||||||||
| 239 | 0 | return $ret; | |||||||||||||||||||
| 240 | } | ||||||||||||||||||||
| 241 | |||||||||||||||||||||
| 242 | sub column | ||||||||||||||||||||
| 243 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
column: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||
| 244 | 0 | my $self = shift; | |||||||||||||||||||
| 245 | 0 | my $query = shift; | |||||||||||||||||||
| 246 | |||||||||||||||||||||
| 247 | 0 | my $ret; | |||||||||||||||||||
| 248 | |||||||||||||||||||||
| 249 | 0 | ▶ | warn $query if $self -> DEBUG; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 250 | |||||||||||||||||||||
| 251 | eval | ||||||||||||||||||||
| 252 | 0 | { | |||||||||||||||||||
| 253 | 0 | $ret = $self -> {dbh} -> selectcol_arrayref($query); | |||||||||||||||||||
| 254 | }; | ||||||||||||||||||||
| 255 | |||||||||||||||||||||
| 256 | 0 | ▶ | if ($@) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 257 | { | ||||||||||||||||||||
| 258 | 0 | warn $@; | |||||||||||||||||||
| 259 | 0 | $self -> {errstr} .= $self -> {dbh} -> errstr; | |||||||||||||||||||
| 260 | 0 | return undef; | |||||||||||||||||||
| 261 | } | ||||||||||||||||||||
| 262 | |||||||||||||||||||||
| 263 | 0 | return @$ret; | |||||||||||||||||||
| 264 | } | ||||||||||||||||||||
| 265 | |||||||||||||||||||||
| 266 | sub hash_all | ||||||||||||||||||||
| 267 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
hash_all: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||
| 268 | 0 | my $self = shift; | |||||||||||||||||||
| 269 | 0 | my $query = shift; | |||||||||||||||||||
| 270 | |||||||||||||||||||||
| 271 | 0 | ▶ | warn $query if $self->DEBUG; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 272 | |||||||||||||||||||||
| 273 | 0 | my %ret; | |||||||||||||||||||
| 274 | my $sth; | ||||||||||||||||||||
| 275 | 0 | my $dbh = $self->{dbh}; | |||||||||||||||||||
| 276 | |||||||||||||||||||||
| 277 | eval | ||||||||||||||||||||
| 278 | 0 | { | |||||||||||||||||||
| 279 | $sth = $dbh->prepare($query) || do | ||||||||||||||||||||
| 280 | 0 | ▶ | { | ||||||||||||||||||
|
Condition0%0/3
$dbh->prepare($query) || do {
warn $dbh->errstr, " $query\n";
$self->{'errstr'} .= $dbh->errstr;
return undef
}
MC/DC0%0/2
$dbh->prepare($query) || do {
warn $dbh->errstr, " $query\n";
$self->{'errstr'} .= $dbh->errstr;
return undef
}
$dbh->prepare($query)
do {
warn $dbh->errstr, " $query\n";
$self->{'errstr'} .= $dbh->errstr;
return undef
}
Truth table0%0/3
A || B
A= $dbh->prepare($query)B= do {
warn $dbh->errstr, " $query\n";
$self->{'errstr'} .= $dbh->errstr;
return undef
}
| |||||||||||||||||||||
| 281 | 0 | warn $dbh->errstr, " $query\n"; | |||||||||||||||||||
| 282 | 0 | $self->{errstr} .= $dbh->errstr; | |||||||||||||||||||
| 283 | 0 | return undef; | |||||||||||||||||||
| 284 | } | ||||||||||||||||||||
| 285 | }; | ||||||||||||||||||||
| 286 | |||||||||||||||||||||
| 287 | eval | ||||||||||||||||||||
| 288 | 0 | { | |||||||||||||||||||
| 289 | $sth->execute || do | ||||||||||||||||||||
| 290 | 0 | ▶ | { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 291 | 0 | warn $dbh->errstr, " $query\n"; | |||||||||||||||||||
| 292 | 0 | $self->{errstr} .= $dbh->errstr; | |||||||||||||||||||
| 293 | 0 | return undef; | |||||||||||||||||||
| 294 | } | ||||||||||||||||||||
| 295 | }; | ||||||||||||||||||||
| 296 | |||||||||||||||||||||
| 297 | 0 | my $ret = $sth->fetchall_arrayref; | |||||||||||||||||||
| 298 | |||||||||||||||||||||
| 299 | 0 | foreach (@$ret) | |||||||||||||||||||
| 300 | { | ||||||||||||||||||||
| 301 | 0 | $ret{$_->[0]} = $_->[1]; | |||||||||||||||||||
| 302 | } | ||||||||||||||||||||
| 303 | |||||||||||||||||||||
| 304 | 0 | return %ret; | |||||||||||||||||||
| 305 | } | ||||||||||||||||||||
| 306 | |||||||||||||||||||||
| 307 | sub hash_row | ||||||||||||||||||||
| 308 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
hash_row: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||
| 309 | 0 | my $self = shift; | |||||||||||||||||||
| 310 | |||||||||||||||||||||
| 311 | 0 | my $query = shift; | |||||||||||||||||||
| 312 | 0 | ▶ | warn $query if $self->DEBUG; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 313 | |||||||||||||||||||||
| 314 | 0 | my $sth; | |||||||||||||||||||
| 315 | 0 | my $dbh = $self->{dbh}; | |||||||||||||||||||
| 316 | |||||||||||||||||||||
| 317 | eval | ||||||||||||||||||||
| 318 | 0 | { | |||||||||||||||||||
| 319 | $sth = $dbh->prepare($query) || do | ||||||||||||||||||||
| 320 | 0 | ▶ | { | ||||||||||||||||||
|
Condition0%0/3
$dbh->prepare($query) || do {
warn $dbh->errstr, " $query\n";
$self->{'errstr'} .= $dbh->errstr;
return undef
}
MC/DC0%0/2
$dbh->prepare($query) || do {
warn $dbh->errstr, " $query\n";
$self->{'errstr'} .= $dbh->errstr;
return undef
}
$dbh->prepare($query)
do {
warn $dbh->errstr, " $query\n";
$self->{'errstr'} .= $dbh->errstr;
return undef
}
Truth table0%0/3
A || B
A= $dbh->prepare($query)B= do {
warn $dbh->errstr, " $query\n";
$self->{'errstr'} .= $dbh->errstr;
return undef
}
| |||||||||||||||||||||
| 321 | 0 | warn $dbh->errstr, " $query\n"; | |||||||||||||||||||
| 322 | 0 | $self->{errstr} .= $dbh->errstr; | |||||||||||||||||||
| 323 | 0 | return undef; | |||||||||||||||||||
| 324 | } | ||||||||||||||||||||
| 325 | }; | ||||||||||||||||||||
| 326 | |||||||||||||||||||||
| 327 | eval | ||||||||||||||||||||
| 328 | 0 | { | |||||||||||||||||||
| 329 | $sth->execute || do | ||||||||||||||||||||
| 330 | 0 | ▶ | { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 331 | 0 | warn $dbh->errstr, " $query\n"; | |||||||||||||||||||
| 332 | 0 | $self->{errstr} .= $dbh->errstr; | |||||||||||||||||||
| 333 | 0 | return undef; | |||||||||||||||||||
| 334 | } | ||||||||||||||||||||
| 335 | }; | ||||||||||||||||||||
| 336 | |||||||||||||||||||||
| 337 | 0 | my $ret = $sth->fetchrow_hashref; | |||||||||||||||||||
| 338 | 0 | $sth->finish; | |||||||||||||||||||
| 339 | |||||||||||||||||||||
| 340 | 0 | return $ret; | |||||||||||||||||||
| 341 | } | ||||||||||||||||||||
| 342 | |||||||||||||||||||||
| 343 | sub hash_var | ||||||||||||||||||||
| 344 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
hash_var: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||
| 345 | 0 | my $self = shift; | |||||||||||||||||||
| 346 | |||||||||||||||||||||
| 347 | 0 | my $query = shift; | |||||||||||||||||||
| 348 | 0 | ▶ | warn $query if $self->DEBUG; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 349 | |||||||||||||||||||||
| 350 | 0 | my $sth; | |||||||||||||||||||
| 351 | 0 | my $dbh = $self->{dbh}; | |||||||||||||||||||
| 352 | |||||||||||||||||||||
| 353 | eval | ||||||||||||||||||||
| 354 | 0 | { | |||||||||||||||||||
| 355 | $sth = $dbh->prepare($query) || do | ||||||||||||||||||||
| 356 | 0 | ▶ | { | ||||||||||||||||||
|
Condition0%0/3
$dbh->prepare($query) || do {
warn $dbh->errstr, " $query\n";
$self->{'errstr'} .= $dbh->errstr;
return undef
}
MC/DC0%0/2
$dbh->prepare($query) || do {
warn $dbh->errstr, " $query\n";
$self->{'errstr'} .= $dbh->errstr;
return undef
}
$dbh->prepare($query)
do {
warn $dbh->errstr, " $query\n";
$self->{'errstr'} .= $dbh->errstr;
return undef
}
Truth table0%0/3
A || B
A= $dbh->prepare($query)B= do {
warn $dbh->errstr, " $query\n";
$self->{'errstr'} .= $dbh->errstr;
return undef
}
| |||||||||||||||||||||
| 357 | 0 | warn $dbh->errstr, " $query\n"; | |||||||||||||||||||
| 358 | 0 | $self->{errstr} .= $dbh->errstr; | |||||||||||||||||||
| 359 | 0 | return undef; | |||||||||||||||||||
| 360 | } | ||||||||||||||||||||
| 361 | }; | ||||||||||||||||||||
| 362 | |||||||||||||||||||||
| 363 | eval | ||||||||||||||||||||
| 364 | 0 | { | |||||||||||||||||||
| 365 | $sth->execute || do | ||||||||||||||||||||
| 366 | 0 | ▶ | { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 367 | 0 | warn $dbh->errstr, " $query\n"; | |||||||||||||||||||
| 368 | 0 | $self->{errstr} .= $dbh->errstr; | |||||||||||||||||||
| 369 | 0 | return undef; | |||||||||||||||||||
| 370 | } | ||||||||||||||||||||
| 371 | }; | ||||||||||||||||||||
| 372 | |||||||||||||||||||||
| 373 | 0 | my $ret = $sth->fetchrow_hashref; | |||||||||||||||||||
| 374 | 0 | $sth->finish; | |||||||||||||||||||
| 375 | |||||||||||||||||||||
| 376 | 0 | ▶ | return ($ret) ? %$ret:undef; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 377 | } | ||||||||||||||||||||
| 378 | |||||||||||||||||||||
| 379 | sub quote | ||||||||||||||||||||
| 380 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
quote: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 381 | 0 | shift -> {dbh} -> quote(@_); | |||||||||||||||||||
| 382 | } | ||||||||||||||||||||
| 383 | |||||||||||||||||||||
| 384 | # Private Methods | ||||||||||||||||||||
| 385 | sub _init | ||||||||||||||||||||
| 386 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
_init: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 387 | 0 | my $self = shift; | |||||||||||||||||||
| 388 | 0 | my %HKeys = @_; | |||||||||||||||||||
| 389 | 0 | my $BStatus = 1; | |||||||||||||||||||
| 390 | |||||||||||||||||||||
| 391 | 0 | $self -> {'database'} = $HKeys{'database'}; | |||||||||||||||||||
| 392 | 0 | $self -> {'user'} = $HKeys{'user'}; | |||||||||||||||||||
| 393 | 0 | $self -> {'password'} = $HKeys{'password'}; | |||||||||||||||||||
| 394 | |||||||||||||||||||||
| 395 | 0 | ▶ | $self -> {'dbh'} = DBI -> connect_cached($self -> {'database'}, $self -> {'user'}, $self -> {'password'}, {ChopBlanks => '1'}) || { $BStatus = 0 }; | ||||||||||||||||||
|
Condition0%0/2
'DBI'->connect_cached($self->{'database'}, $self->{'user'}, $self->{'password'}, {'ChopBlanks', '1'}) || {$BStatus = 0}
MC/DC0%0/1
'DBI'->connect_cached($self->{'database'}, $self->{'user'}, $self->{'password'}, {'ChopBlanks', '1'}) || {$BStatus = 0}
'DBI'->connect_cached($self->{'database'}, $self->{'user'}, $self->{'password'}, {'ChopBlanks', '1'})
Truth table0%0/2
A
A= 'DBI'->connect_cached($self->{'database'}, $self->{'user'}, $self->{'password'}, {'ChopBlanks', '1'})
| |||||||||||||||||||||
| 396 | 0 | $self -> {'connect_status'} = $BStatus; | |||||||||||||||||||
| 397 | } | ||||||||||||||||||||
| 398 | |||||||||||||||||||||
| 399 | |||||||||||||||||||||
| 400 | 1 | 1; | |||||||||||||||||||
| 401 | |||||||||||||||||||||
| 402 | __END__; | ||||||||||||||||||||