line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lemonldap::NG::Common::Conf::RDBI; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
53
|
|
4
|
1
|
|
|
1
|
|
365
|
use Lemonldap::NG::Common::Conf::Serializer; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
38
|
|
5
|
1
|
|
|
1
|
|
397
|
use Lemonldap::NG::Common::Conf::_DBI; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
444
|
|
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
|
|
|
|
|
|
$self->{noQuotes} = 1; |
13
|
0
|
|
|
|
|
|
$fields = $self->serialize($fields); |
14
|
|
|
|
|
|
|
|
15
|
0
|
|
|
|
|
|
my $req; |
16
|
0
|
|
|
|
|
|
my $lastCfg = $self->lastCfg; |
17
|
|
|
|
|
|
|
|
18
|
0
|
0
|
|
|
|
|
if ( $lastCfg == $fields->{cfgNum} ) { |
19
|
0
|
|
|
|
|
|
$req = $self->_dbh->prepare( |
20
|
|
|
|
|
|
|
"UPDATE $self->{dbiTable} SET field=?, value=? WHERE cfgNum=? AND field=?" |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
else { |
25
|
0
|
|
|
|
|
|
$req = $self->_dbh->prepare( |
26
|
|
|
|
|
|
|
"INSERT INTO $self->{dbiTable} (cfgNum,field,value) VALUES (?,?,?)" |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
} |
29
|
0
|
0
|
|
|
|
|
unless ($req) { |
30
|
0
|
|
|
|
|
|
$self->logError; |
31
|
0
|
|
|
|
|
|
return UNKNOWN_ERROR; |
32
|
|
|
|
|
|
|
} |
33
|
0
|
|
|
|
|
|
$self->_dbh->{AutoCommit} = 0; |
34
|
0
|
|
|
|
|
|
while ( my ( $k, $v ) = each %$fields ) { |
35
|
0
|
|
|
|
|
|
my @execValues; |
36
|
0
|
0
|
|
|
|
|
if ( $lastCfg == $fields->{cfgNum} ) { |
37
|
0
|
|
|
|
|
|
@execValues = ( $k, $v, $fields->{cfgNum}, $k ); |
38
|
|
|
|
|
|
|
} |
39
|
0
|
|
|
|
|
|
else { @execValues = ( $fields->{cfgNum}, $k, $v ); } |
40
|
0
|
0
|
|
|
|
|
unless ( $req->execute(@execValues) ) { |
41
|
0
|
|
|
|
|
|
$self->logError; |
42
|
0
|
|
|
|
|
|
$self->_dbh->do("ROLLBACK"); |
43
|
0
|
|
|
|
|
|
$self->_dbh->{AutoCommit} = 1; |
44
|
0
|
|
|
|
|
|
return UNKNOWN_ERROR; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
0
|
|
|
|
|
|
$self->_dbh->do("COMMIT"); |
48
|
0
|
|
|
|
|
|
$self->_dbh->{AutoCommit} = 1; |
49
|
0
|
|
|
|
|
|
return $fields->{cfgNum}; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub load { |
53
|
0
|
|
|
0
|
0
|
|
my ( $self, $cfgNum, $fields ) = @_; |
54
|
0
|
0
|
|
|
|
|
$fields = $fields ? join( ",", @$fields ) : '*'; |
55
|
0
|
|
|
|
|
|
my $sth = |
56
|
|
|
|
|
|
|
$self->_dbh->prepare( "SELECT cfgNum,field,value from " |
57
|
|
|
|
|
|
|
. $self->{dbiTable} |
58
|
|
|
|
|
|
|
. " WHERE cfgNum=?" ); |
59
|
0
|
|
|
|
|
|
$sth->execute($cfgNum); |
60
|
0
|
|
|
|
|
|
my ( $res, @row ); |
61
|
0
|
|
|
|
|
|
while ( @row = $sth->fetchrow_array ) { |
62
|
0
|
|
|
|
|
|
$res->{ $row[1] } = $row[2]; |
63
|
|
|
|
|
|
|
} |
64
|
0
|
0
|
|
|
|
|
unless ($res) { |
65
|
0
|
|
|
|
|
|
$Lemonldap::NG::Common::Conf::msg .= |
66
|
|
|
|
|
|
|
"No configuration $cfgNum found \n"; |
67
|
0
|
|
|
|
|
|
return 0; |
68
|
|
|
|
|
|
|
} |
69
|
0
|
|
|
|
|
|
$res->{cfgNum} = $cfgNum; |
70
|
0
|
|
|
|
|
|
return $self->unserialize($res); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |
74
|
|
|
|
|
|
|
__END__ |