ZofCMS/Plugin/FormToDatabase.pm

filter: Statementstmt 44.0% 11 / 25 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 13 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 60.0% 3 / 5 Podpod 0.0% 0 / 2 totaltotal 25.0% 14 / 56 CC 8 SCAR 38.8
CC
8
Cov
26%
process
72.0
new
2.0
BEGIN
1.0
CRAP 48.4
« ZofCMS/Plugin/NavMaker.pm ↑ Summary ZofCMS/Plugin/GetRemotePageTitle.pm »
1 package App::ZofCMS::Plugin::FormToDatabase;
2  
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 our $VERSION = '1.001010'; # VERSION
7  
8 1 ▶use DBI;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 0 ▶sub new { bless {}, shift }
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
11  
12 0 ▶sub process {
Subroutine process: not called CC=8 SCAR=42.8
Pod undocumented
13 0 my ( $self, $template, $query, $config ) = @_;
14  
15 return
16 unless $template->{plug_form_to_database}
17 0 ▶ or $config->conf->{plug_form_to_database};
Branch: 1 branch
BranchTrueFalseTotal
unless $template->{"plug_form_to_database"} or $config->conf->{"plug_form_to_database"} 0 0 0
Condition0%0/3
$template->{"plug_form_to_database"} or $config->conf->{"plug_form_to_database"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$template->{"plug_form_to_database"} or $config->conf->{"plug_form_to_database"}
$template->{"plug_form_to_database"} $config->conf->{"plug_form_to_database"}
Truth table0%0/3
A or B
A= $template->{"plug_form_to_database"}B= $config->conf->{"plug_form_to_database"}
ABresult
1X1
011
000
18  
19 my %conf = (
20 opt => { RaiseError => 1, AutoCommit => 0 },
21 go_field => 'd|form_to_database',
22 0 ▶ %{ delete $config->conf->{plug_form_to_database} || {} },
Condition0%0/2
delete $config->conf->{'plug_form_to_database'} || {}
l!l
00
MC/DC0%0/1
delete $config->conf->{'plug_form_to_database'} || {}
delete $config->conf->{'plug_form_to_database'}
Truth table0%0/2
A
A= delete $config->conf->{'plug_form_to_database'}
Aresult
11
00
23 0 ▶ %{ delete $template->{plug_form_to_database} || {} },
Condition0%0/2
delete $template->{'plug_form_to_database'} || {}
l!l
00
MC/DC0%0/1
delete $template->{'plug_form_to_database'} || {}
delete $template->{'plug_form_to_database'}
Truth table0%0/2
A
A= delete $template->{'plug_form_to_database'}
Aresult
11
00
24 );
25  
26 # dsn => "DBI:mysql:database=test;host=localhost",
27 # user => 'test', # user,
28 # pass => 'test', # pass
29 # opt => { RaiseError => 1, AutoCommit => 0 },
30  
31 0 my ( $source, $go_name ) = split /\|/, $conf{go_field}, 2;
32  
33 return
34 unless ( $source eq 'q' and $query->{$go_name} )
35 or
36 0 ▶ $template->{$source}{$go_name};
Branch: 1 branch
BranchTrueFalseTotal
unless $source eq "q" and $query->{$go_name} or $template->{$source}{$go_name} 0 0 0
Condition0%0/6
$source eq "q" and $query->{$go_name} or $template->{$source}{$go_name}
l!l&&r!l&&!r
000
$source eq "q" and $query->{$go_name}
!ll&&!rl&&r
000
MC/DC0%0/3
$source eq "q" and $query->{$go_name} or $template->{$source}{$go_name}
$source eq "q" $query->{$go_name} $template->{$source}{$go_name}
Truth table0%0/5
A and B or C
A= $source eq "q"B= $query->{$go_name}C= $template->{$source}{$go_name}
ABCresult
11X1
0X11
1011
0X00
1000
37  
38 0 my @values = @{ $conf{values} };
39  
40 my $dbh = DBI->connect_cached(
41 0 @conf{ qw/dsn user pass opt/ },
42 );
43  
44 $dbh->do(
45 "INSERT INTO $conf{table} VALUES(" . join(q|, |, ('?')x@values) . ');',
46 undef,
47 0 @$query{ @values },
48 );
49 0 $dbh->disconnect;
50  
51 0 return 1;
52 }
53  
54 1 1;
55 __END__
« ZofCMS/Plugin/NavMaker.pm ↑ Summary ZofCMS/Plugin/GetRemotePageTitle.pm »