[Bio] / Sprout / ERDB.pm Repository:
ViewVC logotype

Diff of /Sprout/ERDB.pm

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

revision 1.90, Fri Apr 27 22:19:49 2007 UTC revision 1.91, Wed May 2 05:51:48 2007 UTC
# Line 372  Line 372 
372                   'medium-string' =>                   'medium-string' =>
373                               { sqlType => 'VARCHAR(160)',       maxLen => 160,          avgLen =>  40, sort => "",                               { sqlType => 'VARCHAR(160)',       maxLen => 160,          avgLen =>  40, sort => "",
374                                 indexMod =>   0, notes => "character string, 0 to 160 characters"},                                 indexMod =>   0, notes => "character string, 0 to 160 characters"},
375                     'long-string' =>
376                                 { sqlType => 'VARCHAR(500)',       maxLen => 500,          avglen => 255, sort => "",
377                                   indexMod =>   0, notes => "character string, 0 to 500 characters"},
378                  );                  );
379    
380  # Table translating arities into natural language.  # Table translating arities into natural language.
# Line 2063  Line 2066 
2066      $dbh->SQL($command, undef, @parms);      $dbh->SQL($command, undef, @parms);
2067  }  }
2068    
2069    =head3 DeleteLike
2070    
2071    C<< my $deleteCount = $erdb->DeleteLike($relName, $filter, \@parms); >>
2072    
2073    Delete all the relationship rows that satisfy a particular filter condition. Unlike a normal
2074    filter, only fields from the relationship itself can be used.
2075    
2076    =over 4
2077    
2078    =item relName
2079    
2080    Name of the relationship whose records are to be deleted.
2081    
2082    =item filter
2083    
2084    A filter clause (L</Get>-style) for the delete query.
2085    
2086    =item parms
2087    
2088    Reference to a list of parameters for the filter clause.
2089    
2090    =item RETURN
2091    
2092    Returns a count of the number of rows deleted.
2093    
2094    =back
2095    
2096    =cut
2097    
2098    sub DeleteLike {
2099        # Get the parameters.
2100        my ($self, $objectName, $filter, $parms) = @_;
2101        # Declare the return variable.
2102        my $retVal;
2103        # Insure the parms argument is an array reference if the caller left it off.
2104        if (! defined($parms)) {
2105            $parms = [];
2106        }
2107        # Insure we have a relationship. The main reason for this is if we delete an entity
2108        # instance we have to yank out a bunch of other stuff with it.
2109        if ($self->IsEntity($objectName)) {
2110            Confess("Cannot use DeleteLike on $objectName, because it is not a relationship.");
2111        } else {
2112            # Create the SQL command suffix to get the desierd records.
2113            my ($suffix) = $self->_SetupSQL([$objectName], $filter);
2114            # Convert it to a DELETE command.
2115            my $command = "DELETE $suffix";
2116            # Execute the command.
2117            my $dbh = $self->{_dbh};
2118            my $result = $dbh->SQL($command, 0, @{$parms});
2119            # Check the results. Note we convert the "0D0" result to a real zero.
2120            # A failure causes an abnormal termination, so the caller isn't going to
2121            # worry about it.
2122            if (! defined $result) {
2123                Confess("Error deleting from $objectName: " . $dbh->errstr());
2124            } elsif ($result == 0) {
2125                $retVal = 0;
2126            } else {
2127                $retVal = $result;
2128            }
2129        }
2130        # Return the result count.
2131        return $retVal;
2132    }
2133    
2134  =head3 SortNeeded  =head3 SortNeeded
2135    
2136  C<< my $parms = $erdb->SortNeeded($relationName); >>  C<< my $parms = $erdb->SortNeeded($relationName); >>

Legend:
Removed from v.1.90  
changed lines
  Added in v.1.91

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3