Portal/RDB.pm

filter: Statementstmt 40.7% 11 / 27 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 3 / 6 Podpod 0.0% 0 / 3 totaltotal 36.8% 14 / 38 CC 3 SCAR 12.9
CC
3
Cov
38%
escape
6.0
exec
6.0
new
2.0
CRAP 3.6
« Portal/Scripts/profile.pm ↑ Summary Portal/Scripts/changepw.pm »
1 package CGI::Portal::RDB;
2 # Copyright (c) 2008 Alexander David P. All rights reserved.
3 #
4 # Database class
5  
6 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use DBI;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 $VERSION = "0.12";
11  
12 1 1;
13  
14 # Connect to database and store handle in a rdb object
15 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
16 0 my ($class, $dsn, $user, $passw) = @_;
17 0 my $i = {};
18  
19 0 $i->{'dbh'} = DBI->connect($dsn, $user, $passw);
20  
21 0 bless $i, $class;
22 0 return $i;
23 }
24  
25 # Loop thru vals, escape them and join by commas
26 0 ▶sub escape {
Subroutine escape: not called CC=2 SCAR=17.9
Pod undocumented
27 0 my ($self, @vals) = @_;
28 0 my @esc_vals;
29  
30 0 foreach my $a (@vals) {
31 0 push(@esc_vals, $self->{'dbh'}->quote($a));
32 }
33  
34 0 return join(',', @esc_vals);
35 }
36  
37 # Execute query and return statement handle
38 0 ▶sub exec {
Subroutine exec: not called CC=2 SCAR=17.9
Pod undocumented
39 0 my ($self, $sql) = @_;
40  
41 0 ▶ unless ($self->{'dbh'}){return;}
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"dbh"}) 0 0 0
42  
43 0 my $sth = $self->{'dbh'}->prepare($sql);
44 0 $sth->execute();
45  
46 0 return $sth;
47 }
« Portal/Scripts/profile.pm ↑ Summary Portal/Scripts/changepw.pm »