/[cvs]/nfo/perl/libs/Data/Storage/Handler/DBI.pm
ViewVC logotype

Diff of /nfo/perl/libs/Data/Storage/Handler/DBI.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.15 by joko, Wed Apr 9 07:53:33 2003 UTC revision 1.16 by joko, Fri Apr 11 01:17:18 2003 UTC
# Line 3  Line 3 
3  #  $Id$  #  $Id$
4  #  #
5  #  $Log$  #  $Log$
6    #  Revision 1.16  2003/04/11 01:17:18  joko
7    #  sendQuery:
8    #  + introduced crud action 'DELETE'
9    #  + some pre-flight checks
10    #
11  #  Revision 1.15  2003/04/09 07:53:33  joko  #  Revision 1.15  2003/04/09 07:53:33  joko
12  #  minor namespace update  #  minor namespace update
13  #  #
# Line 144  sub _sendSql { Line 149  sub _sendSql {
149    my $self = shift;    my $self = shift;
150    my $sql = shift;    my $sql = shift;
151        
152      # pre-flight check: is $sql defined?
153      if (!$sql) {
154        $logger->warning( __PACKAGE__ . "->_sendSql: \$sql was empty." );
155        return;
156      }
157      
158    # two-level handling for implicit connect:    # two-level handling for implicit connect:
159    # if there's no corehandle ...    # if there's no corehandle ...
160    if (!$self->{_COREHANDLE}) {    if (!$self->{_COREHANDLE}) {
# Line 207  sub sendQuery { Line 218  sub sendQuery {
218    
219    $logger->debug( __PACKAGE__ . "->sendQuery" );    $logger->debug( __PACKAGE__ . "->sendQuery" );
220    
221    my $action = $query->{options}->{action};    my $crud = $query->{options}->{crud};
222    $action ||= 'load';    $crud ||= $query->{options}->{action};
223      $crud ||= 'RETRIEVE';
224    
225    if (my $guid = $query->{options}->{GUID}) {    if (my $guid = $query->{options}->{GUID}) {
226      $query->{criterias} = [ { key => 'guid', op => 'eq', val => $guid } ];      $query->{criterias} = [ { key => 'guid', op => 'eq', val => $guid } ];
# Line 235  sub sendQuery { Line 247  sub sendQuery {
247    #$subnodes ||= $query->{payload};    #$subnodes ||= $query->{payload};
248        
249    # dispatch action    # dispatch action
250    if ($action eq 'load') {    if ($crud eq 'RETRIEVE') {
251      my $sql = hash2sql($query->{node}, $subnodes, 'SELECT', $crit);      my $sql = hash2sql($query->{node}, $subnodes, 'SELECT', $crit);
252      return $self->sendCommand($sql);      return $self->sendCommand($sql);
253    } elsif ($action eq 'save') {  
254      } elsif ($crud eq 'UPDATE') {
255      my $sql = hash2sql($query->{node}, $query->{payload}, 'UPDATE', $crit);      my $sql = hash2sql($query->{node}, $query->{payload}, 'UPDATE', $crit);
256      $self->sendCommand($sql);      $self->sendCommand($sql);
257    
258      } elsif ($crud eq 'DELETE') {
259        my $sql = hash2sql($query->{node}, $query->{payload}, 'DELETE', $crit);
260        $self->sendCommand($sql);
261    
262    }    }
263    
264  }  }

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.16

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed