/usr/share/perl5/Lemonldap/NG/Common/Conf/RDBI.pm is in liblemonldap-ng-common-perl 1.9.16-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | package Lemonldap::NG::Common::Conf::RDBI;
use strict;
use utf8;
use Lemonldap::NG::Common::Conf::Serializer;
use Lemonldap::NG::Common::Conf::_DBI;
our $VERSION = '1.9.13';
our @ISA = qw(Lemonldap::NG::Common::Conf::_DBI);
sub store {
my ( $self, $fields ) = @_;
my $cfgNum = $fields->{cfgNum};
$self->{noQuotes} = 1;
$fields = $self->serialize($fields);
my $req;
my $lastCfg = $self->lastCfg;
if ( $lastCfg == $cfgNum ) {
$req = $self->_dbh->prepare(
"UPDATE $self->{dbiTable} SET field=?, value=? WHERE cfgNum=? AND field=?"
);
}
else {
$req = $self->_dbh->prepare(
"INSERT INTO $self->{dbiTable} (cfgNum,field,value) VALUES (?,?,?)"
);
}
unless ($req) {
$self->logError;
return UNKNOWN_ERROR;
}
while ( my ( $k, $v ) = each %$fields ) {
my @execValues;
if ( $lastCfg == $cfgNum ) {
@execValues = ( $k, $v, $cfgNum, $k );
}
else { @execValues = ( $cfgNum, $k, $v ); }
my $execute;
eval { $execute = $req->execute(@execValues); };
unless ($execute) {
$self->logError;
$self->_dbh->do("ROLLBACK");
return UNKNOWN_ERROR;
}
}
return $cfgNum;
}
sub load {
my ( $self, $cfgNum, $fields ) = @_;
$fields = $fields ? join( ",", @$fields ) : '*';
my $sth =
$self->_dbh->prepare( "SELECT cfgNum,field,value from "
. $self->{dbiTable}
. " WHERE cfgNum=?" );
$sth->execute($cfgNum);
my ( $res, @row );
while ( @row = $sth->fetchrow_array ) {
$res->{ $row[1] } = $row[2];
}
unless ($res) {
$Lemonldap::NG::Common::Conf::msg .=
"No configuration $cfgNum found \n";
return 0;
}
$res->{cfgNum} = $cfgNum;
return $self->unserialize($res);
}
1;
__END__
|