line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package GBPVR::CDBI; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
30497
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
133
|
|
4
|
4
|
|
|
4
|
|
24
|
use strict; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
217
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
7
|
|
|
|
|
|
|
|
8
|
4
|
|
|
4
|
|
20
|
use base 'Class::DBI'; |
|
4
|
|
|
|
|
13
|
|
|
4
|
|
|
|
|
6775
|
|
9
|
4
|
|
|
4
|
|
374847
|
use Win32::TieRegistry; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use File::Spec; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $gbpvr_dir = $Registry->{'LMachine\software\devnz\GBPVR InstallDir'} || 'C:\program files\devnz\gbpvr'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
__PACKAGE__->db_setup(file => 'gbpvr.mdb'); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub db_setup { |
17
|
|
|
|
|
|
|
my $self = shift; |
18
|
|
|
|
|
|
|
my $p = { @_ }; |
19
|
|
|
|
|
|
|
my $file = $p->{file}; |
20
|
|
|
|
|
|
|
$file = File::Spec->rel2abs($file, $gbpvr_dir); # if file was a relative path, make it full with respect to GBPVR |
21
|
|
|
|
|
|
|
my $dbopts = $p->{dbopts} || { AutoCommit=>0, LongTruncOk => 1, LongReadLen => 255 }; |
22
|
|
|
|
|
|
|
my $dsn = 'driver=Microsoft Access Driver (*.mdb);dbq=' . $file; |
23
|
|
|
|
|
|
|
my $rc; |
24
|
|
|
|
|
|
|
# trap errors, specifically for the case that GBPVR isn't installed so the |
25
|
|
|
|
|
|
|
# default mdb's don't exist (e.g. for cpan-testers) |
26
|
|
|
|
|
|
|
eval { $rc = $self->set_db('Main', "dbi:ODBC:$dsn", '', '', $dbopts ); }; |
27
|
|
|
|
|
|
|
warn "ERROR in db_setup('$file'): $@" if $@; |
28
|
|
|
|
|
|
|
return $rc; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
1; |
32
|
|
|
|
|
|
|
__END__ |