line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CGI::Portal::RDB; |
2
|
|
|
|
|
|
|
# Copyright (c) 2008 Alexander David P. All rights reserved. |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# Database class |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
10
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
38
|
|
7
|
1
|
|
|
1
|
|
2384
|
use DBI; |
|
1
|
|
|
|
|
48040
|
|
|
1
|
|
|
|
|
192
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
12
|
use vars qw($VERSION); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
308
|
|
10
|
|
|
|
|
|
|
$VERSION = "0.12"; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
1; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# Connect to database and store handle in a rdb object |
15
|
|
|
|
|
|
|
sub new { |
16
|
0
|
|
|
0
|
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
|
|
|
|
|
|
|
sub escape { |
27
|
0
|
|
|
0
|
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
|
|
|
|
|
|
|
sub exec { |
39
|
0
|
|
|
0
|
0
|
|
my ($self, $sql) = @_; |
40
|
|
|
|
|
|
|
|
41
|
0
|
0
|
|
|
|
|
unless ($self->{'dbh'}){return;} |
|
0
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
my $sth = $self->{'dbh'}->prepare($sql); |
44
|
0
|
|
|
|
|
|
$sth->execute(); |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
return $sth; |
47
|
|
|
|
|
|
|
} |