--- nfo/perl/libs/Data/Storage/Handler/DBI.pm 2003/04/09 07:53:33 1.15 +++ nfo/perl/libs/Data/Storage/Handler/DBI.pm 2003/04/11 01:17:18 1.16 @@ -1,8 +1,13 @@ ################################# # -# $Id: DBI.pm,v 1.15 2003/04/09 07:53:33 joko Exp $ +# $Id: DBI.pm,v 1.16 2003/04/11 01:17:18 joko Exp $ # # $Log: DBI.pm,v $ +# Revision 1.16 2003/04/11 01:17:18 joko +# sendQuery: +# + introduced crud action 'DELETE' +# + some pre-flight checks +# # Revision 1.15 2003/04/09 07:53:33 joko # minor namespace update # @@ -144,6 +149,12 @@ my $self = shift; my $sql = shift; + # pre-flight check: is $sql defined? + if (!$sql) { + $logger->warning( __PACKAGE__ . "->_sendSql: \$sql was empty." ); + return; + } + # two-level handling for implicit connect: # if there's no corehandle ... if (!$self->{_COREHANDLE}) { @@ -207,8 +218,9 @@ $logger->debug( __PACKAGE__ . "->sendQuery" ); - my $action = $query->{options}->{action}; - $action ||= 'load'; + my $crud = $query->{options}->{crud}; + $crud ||= $query->{options}->{action}; + $crud ||= 'RETRIEVE'; if (my $guid = $query->{options}->{GUID}) { $query->{criterias} = [ { key => 'guid', op => 'eq', val => $guid } ]; @@ -235,12 +247,18 @@ #$subnodes ||= $query->{payload}; # dispatch action - if ($action eq 'load') { + if ($crud eq 'RETRIEVE') { my $sql = hash2sql($query->{node}, $subnodes, 'SELECT', $crit); return $self->sendCommand($sql); - } elsif ($action eq 'save') { + + } elsif ($crud eq 'UPDATE') { my $sql = hash2sql($query->{node}, $query->{payload}, 'UPDATE', $crit); $self->sendCommand($sql); + + } elsif ($crud eq 'DELETE') { + my $sql = hash2sql($query->{node}, $query->{payload}, 'DELETE', $crit); + $self->sendCommand($sql); + } }