« blib/lib/Lemonldap/NG/Common/PSGI/SOAPServer.pm
↑ Summary
blib/lib/Lemonldap/NG/Common/Util/Crypto.pm »
| 1 | package Lemonldap::NG::Common::Conf::Backends::CDBI; | ||||||||||
| 2 | |||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 3 | ▶ | use utf8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 3 | ▶ | use JSON; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 3 | ▶ | use Lemonldap::NG::Common::Conf::Backends::_DBI; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 3 | our $VERSION = '2.22.0'; | |||||||||
| 9 | 3 | our @ISA = qw(Lemonldap::NG::Common::Conf::Backends::_DBI); | |||||||||
| 10 | |||||||||||
| 11 | 15 | ▶ | sub store { | ||||||||
|
Subroutine
store: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||
| 12 | 15 | my ( $self, $fields ) = @_; | |||||||||
| 13 | 15 | my $cfgNum = $fields->{cfgNum}; | |||||||||
| 14 | 15 | my $req; | |||||||||
| 15 | 15 | my $lastCfg = $self->lastCfg; | |||||||||
| 16 | |||||||||||
| 17 | 15 | $fields = to_json($fields); | |||||||||
| 18 | |||||||||||
| 19 | 15 | ▶ | my $query = | ||||||||
|
Branch: 1 branch
| |||||||||||
| 20 | $lastCfg == $cfgNum | ||||||||||
| 21 | ? "UPDATE $self->{dbiTable} SET data=? WHERE cfgNum=?" | ||||||||||
| 22 | : "INSERT INTO $self->{dbiTable} (data,cfgNum) VALUES (?,?)"; | ||||||||||
| 23 | 15 | my $res = $self->_execute( $query, $fields, $cfgNum ); | |||||||||
| 24 | 8 | ▶ | return $res > 0 ? $cfgNum : $res; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | 9 | ▶ | sub load { | ||||||||
|
Subroutine
load: called CC=5 SCAR=19.3
Pod
undocumented
| |||||||||||
| 28 | 9 | my ( $self, $cfgNum, $fields ) = @_; | |||||||||
| 29 | 9 | ▶ | $fields = $fields ? join( ",", @$fields ) : '*'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 30 | my ( $res, $row ) = $self->_execute( | ||||||||||
| 31 | 9 | "SELECT data from " . $self->{dbiTable} . " WHERE cfgNum=?", $cfgNum ); | |||||||||
| 32 | 9 | ▶ | if ( $res > 0 ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | 9 | $row = $row->fetchrow_arrayref(); | |||||||||
| 34 | } | ||||||||||
| 35 | else { | ||||||||||
| 36 | 0 | $self->logError; | |||||||||
| 37 | 0 | return 0; | |||||||||
| 38 | } | ||||||||||
| 39 | 9 | my $r; | |||||||||
| 40 | 9 | ▶ | if ( $row->[0] =~ /^\s*\{/s ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | 9 | eval { $r = from_json( $row->[0], { allow_nonref => 1 } ); }; | |||||||||
| 42 | } | ||||||||||
| 43 | else { # Old format | ||||||||||
| 44 | 0 | require Storable; | |||||||||
| 45 | 0 | eval { $r = Storable::thaw( $row->[0] ); }; | |||||||||
| 46 | } | ||||||||||
| 47 | 9 | ▶ | if ($@) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 48 | 0 | $Lemonldap::NG::Common::Conf::msg .= | |||||||||
| 49 | "Bad stored data in conf database: $@ \n"; | ||||||||||
| 50 | 0 | return 0; | |||||||||
| 51 | } | ||||||||||
| 52 | 9 | return $r; | |||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | 3 | 1; | |||||||||
| 56 | __END__ | ||||||||||