2008-11-17 17:59:56 +01:00
|
|
|
package Lemonldap::NG::Common::Conf::DBI;
|
2006-12-18 12:32:33 +01:00
|
|
|
|
|
|
|
use strict;
|
2009-10-20 15:20:53 +02:00
|
|
|
use Lemonldap::NG::Common::Conf::Serializer;
|
2010-09-17 11:26:03 +02:00
|
|
|
use Lemonldap::NG::Common::Conf::_DBI;
|
2006-12-18 12:32:33 +01:00
|
|
|
|
2010-09-17 11:26:03 +02:00
|
|
|
our $VERSION = 0.2;
|
|
|
|
our @ISA = qw(Lemonldap::NG::Common::Conf::_DBI);
|
2006-12-18 12:32:33 +01:00
|
|
|
|
|
|
|
sub store {
|
2007-01-04 09:42:13 +01:00
|
|
|
my ( $self, $fields ) = @_;
|
2010-01-01 13:04:26 +01:00
|
|
|
return DEPRECATED unless ( $self->{forceUpload} );
|
2009-11-01 14:13:39 +01:00
|
|
|
$fields = $self->serialize($fields);
|
2007-01-04 09:42:13 +01:00
|
|
|
my $tmp =
|
2010-09-17 11:26:03 +02:00
|
|
|
$self->_dbh->do( "insert into "
|
2007-01-04 09:42:13 +01:00
|
|
|
. $self->{dbiTable} . " ("
|
|
|
|
. join( ",", keys(%$fields) )
|
|
|
|
. ") values ("
|
|
|
|
. join( ",", values(%$fields) )
|
|
|
|
. ")" );
|
|
|
|
unless ($tmp) {
|
2007-03-04 15:52:51 +01:00
|
|
|
$self->logError;
|
|
|
|
return UNKNOWN_ERROR;
|
|
|
|
}
|
2009-12-15 17:31:13 +01:00
|
|
|
eval { $self->dbh->do("COMMIT"); };
|
2008-11-22 19:09:57 +01:00
|
|
|
unless ( $self->unlock ) {
|
2007-03-04 15:52:51 +01:00
|
|
|
$self->logError;
|
2006-12-18 12:32:33 +01:00
|
|
|
}
|
|
|
|
return $fields->{cfgNum};
|
|
|
|
}
|
|
|
|
|
|
|
|
sub load {
|
2007-01-04 09:42:13 +01:00
|
|
|
my ( $self, $cfgNum, $fields ) = @_;
|
2007-03-23 21:28:28 +01:00
|
|
|
$fields = $fields ? join( ",", @$fields ) : '*';
|
2010-09-17 11:26:03 +02:00
|
|
|
my $row = $self->_dbh->selectrow_hashref(
|
2007-01-04 09:42:13 +01:00
|
|
|
"SELECT $fields from " . $self->{dbiTable} . " WHERE cfgNum=$cfgNum" );
|
|
|
|
unless ($row) {
|
2007-03-04 15:52:51 +01:00
|
|
|
$self->logError;
|
|
|
|
return 0;
|
2006-12-18 12:32:33 +01:00
|
|
|
}
|
2009-10-20 15:20:53 +02:00
|
|
|
return $self->unserialize($row);
|
2006-12-18 12:32:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
1;
|
|
|
|
__END__
|