| 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
Condition0%0/3
$template->{"plug_form_to_database"} or $config->conf->{"plug_form_to_database"}
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"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 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'} || {}
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'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | ▶ | %{ delete $template->{plug_form_to_database} || {} }, | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
delete $template->{'plug_form_to_database'} || {}
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'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition0%0/6
$source eq "q" and $query->{$go_name} or $template->{$source}{$go_name}
$source eq "q" and $query->{$go_name}
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}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||||||||||||||||||||