Browseable/Store/DBI.pm

filter: Statementstmt 100% 39 / 39 Branchbran 50.0% 3 / 6 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 2 totaltotal 83.9% 47 / 56 CC 7 SCAR 12.3
CC
7
Cov
90%
insert
4.1
update
4.0
BEGIN
1.0
CRAP 3.4
« Browseable/_common.pm ↑ Summary Serialize/JSON.pm »
1 package Apache::Session::Browseable::Store::DBI;
2  
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use Apache::Session::Store::DBI;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 our @ISA = qw(Apache::Session::Store::DBI);
6 4 our $VERSION = 1.3.11;
7  
8 29 ▶sub insert {
Subroutine insert: called CC=4 SCAR=14.0
Pod undocumented
9 29 my ( $self, $session ) = @_;
10  
11 29 $self->connection($session);
12  
13 29 local $self->{dbh}->{RaiseError} = 1;
14  
15 my $index =
16 ref( $session->{args}->{Index} )
17 ? $session->{args}->{Index}
18 29 ▶ : [ split /\s+/, $session->{args}->{Index} ];
Branch: 1 branch
BranchTrueFalseTotal
ref $session->{'args'}{'Index'} ? : 0 29 29
19  
20 $self->{insert_sth} //=
21 $self->{dbh}->prepare_cached( "INSERT INTO $self->{table_name} ("
22 29 ▶ . join( ',', 'id', 'a_session', map { s/'/''/g; $_ } @$index )
Condition33%1/3
$self->{"insert_sth"} //= $self->{"dbh"}->prepare_cached(qq[INSERT INTO $self->{"table_name"} (] . join(",", "id", "a_session", map({s/'/''/g; $_;} @$index)) . ') VALUES (' . join(",", ("?") x (2 + @$index)) . ')')
l!l&&r!l&&!r
0290
MC/DC0%0/2
$self->{"insert_sth"} //= $self->{"dbh"}->prepare_cached(qq[INSERT INTO $self->{"table_name"} (] . join(",", "id", "a_session", map({s/'/''/g; $_;} @$index)) . ') VALUES (' . join(",", ("?") x (2 + @$index)) . ')')
$self->{"insert_sth"} $self->{"dbh"}->prepare_cached(qq[INSERT INTO $self->{"table_name"} (] . join(",", "id", "a_session", map({s/'/''/g; $_;} @$index)) . ') VALUES (' . join(",", ("?") x (2 + @$index)) . ')')
Truth table33%1/3
A //= B
A= $self->{"insert_sth"}B= $self->{"dbh"}->prepare_cached(qq[INSERT INTO $self->{"table_name"} (] . join(",", "id", "a_session", map({s/'/''/g; $_;} @$index)) . ') VALUES (' . join(",", ("?") x (2 + @$index)) . ')')
ABresult
1X1
011
000
23 . ') VALUES ('
24 . join( ',', ('?') x ( 2 + @$index ) )
25 . ')' );
26  
27 29 $self->{insert_sth}->bind_param( 1, $session->{data}->{_session_id} );
28 29 $self->{insert_sth}->bind_param( 2, $session->{serialized} );
29 29 my $i = 3;
30 29 foreach my $f (@$index) {
31 56 $self->{insert_sth}->bind_param( $i, $session->{data}->{$f} );
32 56 $i++;
33 }
34  
35 29 $self->{insert_sth}->execute;
36  
37 29 $self->{insert_sth}->finish;
38 }
39  
40 29 ▶sub update {
Subroutine update: called CC=4 SCAR=13.9
Pod undocumented
41 29 my $self = shift;
42 29 my $session = shift;
43  
44 29 $self->connection($session);
45  
46 29 local $self->{dbh}->{RaiseError} = 1;
47  
48 my $index =
49 ref( $session->{args}->{Index} )
50 ? $session->{args}->{Index}
51 29 ▶ : [ split /\s+/, $session->{args}->{Index} ];
Branch: 1 branch
BranchTrueFalseTotal
ref $session->{'args'}{'Index'} ? : 0 29 29
52  
53 29 ▶ if ( !defined $self->{update_sth} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"update_sth"}) 29 0 29
54 $self->{update_sth} =
55 29 $self->{dbh}->prepare_cached( "UPDATE $self->{table_name} SET "
56 . join( ' = ?, ', 'a_session', @$index )
57 . ' = ? WHERE id = ?' );
58 }
59  
60 29 $self->{update_sth}->bind_param( 1, $session->{serialized} );
61 29 my $i = 2;
62 29 foreach my $f (@$index) {
63 56 $self->{update_sth}->bind_param( $i, $session->{data}->{$f} );
64 56 $i++;
65 }
66 29 $self->{update_sth}->bind_param( $i, $session->{data}->{_session_id} );
67  
68 29 $self->{update_sth}->execute;
69  
70 29 $self->{update_sth}->finish;
71 }
72  
73 4 1;
« Browseable/_common.pm ↑ Summary Serialize/JSON.pm »