| 1 | package CGI::Ex::Recipes::Add; | ||||||||||||
| 2 | 1 | ▶ | use utf8; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 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 | 1 | ▶ | use base qw(CGI::Ex::Recipes); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 1 | our $VERSION = sprintf "%d.%03d", q$Revision 0.001$ =~ /(\d+)/g; | |||||||||||
| 7 | |||||||||||||
| 8 | |||||||||||||
| 9 | 0 | ▶ | sub skip { 0 } | ||||||||||
|
Subroutine
skip: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 10 | 0 | ▶ | sub name_step { 'edit' } | ||||||||||
|
Subroutine
name_step: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 11 | |||||||||||||
| 12 | |||||||||||||
| 13 | 0 | ▶ | sub finalize { | ||||||||||
|
Subroutine
finalize: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||
| 14 | 0 | my $self = shift; | |||||||||||
| 15 | 0 | my $form = $self->form; | |||||||||||
| 16 | |||||||||||||
| 17 | 0 | my $s = "SELECT COUNT(*) FROM recipes WHERE title = ?"; | |||||||||||
| 18 | 0 | my ($count) = $self->dbh->selectrow_array($s, {}, $form->{'title'}); | |||||||||||
| 19 | 0 | ▶ | if ($count) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 20 | 0 | $self->add_errors(title => 'A recipe by this title already exists'); | |||||||||||
| 21 | 0 | return 0; | |||||||||||
| 22 | } | ||||||||||||
| 23 | |||||||||||||
| 24 | 0 | $s = "INSERT INTO recipes (pid, is_category, title, problem, analysis, solution, sortorder, tstamp, date_added) | |||||||||||
| 25 | VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"; | ||||||||||||
| 26 | 0 | my $tstamp = $self->now; | |||||||||||
| 27 | $self->dbh->prepare($s)->execute( | ||||||||||||
| 28 | $form->{'pid'}, | ||||||||||||
| 29 | $form->{'is_category'}||0, | ||||||||||||
| 30 | $form->{'title'}, | ||||||||||||
| 31 | $form->{'problem'}, | ||||||||||||
| 32 | $form->{'analysis'}, | ||||||||||||
| 33 | $form->{'solution'}, | ||||||||||||
| 34 | 0 | ▶ | $form->{'sortorder'}, | ||||||||||
|
Condition0%0/2
$form->{'is_category'} || 0
MC/DC0%0/1
$form->{'is_category'} || 0
$form->{'is_category'}
Truth table0%0/2
A
A= $form->{'is_category'}
| |||||||||||||
| 35 | $tstamp, | ||||||||||||
| 36 | $tstamp,); | ||||||||||||
| 37 | 0 | $self->add_to_form(success => "Recipe added to the database"); | |||||||||||
| 38 | 0 | return 1; | |||||||||||
| 39 | } | ||||||||||||
| 40 | |||||||||||||
| 41 | 1 | 1; # End of CGI::Ex::Recipes::Add | |||||||||||
| 42 | |||||||||||||
| 43 | __END__ | ||||||||||||