line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lemonldap::NG::Common::Conf::CDBI; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
55
|
|
4
|
|
|
|
|
|
|
require Storable; |
5
|
1
|
|
|
1
|
|
634
|
use Lemonldap::NG::Common::Conf::_DBI; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
666
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '1.4.0'; |
8
|
|
|
|
|
|
|
our @ISA = qw(Lemonldap::NG::Common::Conf::_DBI); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub store { |
11
|
0
|
|
|
0
|
0
|
|
my ( $self, $fields ) = @_; |
12
|
0
|
|
|
|
|
|
my $cfgNum = $fields->{cfgNum}; |
13
|
0
|
|
|
|
|
|
my $req; |
14
|
0
|
|
|
|
|
|
my $lastCfg = $self->lastCfg; |
15
|
|
|
|
|
|
|
|
16
|
0
|
|
|
|
|
|
$fields = Storable::nfreeze($fields); |
17
|
|
|
|
|
|
|
|
18
|
0
|
0
|
|
|
|
|
if ( $lastCfg == $cfgNum ) { |
19
|
0
|
|
|
|
|
|
$req = $self->_dbh->prepare( |
20
|
|
|
|
|
|
|
"UPDATE $self->{dbiTable} SET data=? WHERE cfgNum=?"); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
else { |
23
|
0
|
|
|
|
|
|
$req = $self->_dbh->prepare( |
24
|
|
|
|
|
|
|
"INSERT INTO $self->{dbiTable} (data,cfgNum) VALUES (?,?)"); |
25
|
|
|
|
|
|
|
} |
26
|
0
|
0
|
|
|
|
|
unless ($req) { |
27
|
0
|
|
|
|
|
|
$self->logError; |
28
|
0
|
|
|
|
|
|
return UNKNOWN_ERROR; |
29
|
|
|
|
|
|
|
} |
30
|
0
|
0
|
|
|
|
|
unless ( $req->execute( $fields, $cfgNum ) ) { |
31
|
0
|
|
|
|
|
|
$self->logError; |
32
|
0
|
|
|
|
|
|
return UNKNOWN_ERROR; |
33
|
|
|
|
|
|
|
} |
34
|
0
|
|
|
|
|
|
eval { $self->_dbh->do("COMMIT"); }; |
|
0
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
return $cfgNum; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub load { |
39
|
0
|
|
|
0
|
0
|
|
my ( $self, $cfgNum, $fields ) = @_; |
40
|
0
|
0
|
|
|
|
|
$fields = $fields ? join( ",", @$fields ) : '*'; |
41
|
0
|
|
|
|
|
|
my $row = $self->_dbh->selectrow_arrayref( |
42
|
|
|
|
|
|
|
"SELECT data from " . $self->{dbiTable} . " WHERE cfgNum=?", |
43
|
|
|
|
|
|
|
{}, $cfgNum ); |
44
|
0
|
0
|
|
|
|
|
unless ($row) { |
45
|
0
|
|
|
|
|
|
$self->logError; |
46
|
0
|
|
|
|
|
|
return 0; |
47
|
|
|
|
|
|
|
} |
48
|
0
|
|
|
|
|
|
my $r; |
49
|
0
|
|
|
|
|
|
eval { $r = Storable::thaw( $row->[0] ); }; |
|
0
|
|
|
|
|
|
|
50
|
0
|
0
|
|
|
|
|
if ($@) { |
51
|
0
|
|
|
|
|
|
$Lemonldap::NG::Common::Conf::msg .= |
52
|
|
|
|
|
|
|
"Bad stored data in conf database: $@ \n"; |
53
|
0
|
|
|
|
|
|
return 0; |
54
|
|
|
|
|
|
|
} |
55
|
0
|
|
|
|
|
|
return $r; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |
59
|
|
|
|
|
|
|
__END__ |