[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.78, Tue Nov 28 01:02:42 2006 UTC revision 1.79, Wed Nov 29 20:29:53 2006 UTC
# Line 1852  Line 1852 
1852      }      }
1853  }  }
1854    
1855    =head3 DeleteRow
1856    
1857    C<< $erdb->DeleteRow($relationshipName, $fromLink, $toLink, \%values); >>
1858    
1859    Delete a row from a relationship. In most cases, only the from-link and to-link are
1860    needed; however, for relationships with intersection data values can be specified
1861    for the other fields using a hash.
1862    
1863    =over 4
1864    
1865    =item relationshipName
1866    
1867    Name of the relationship from which the row is to be deleted.
1868    
1869    =item fromLink
1870    
1871    ID of the entity instance in the From direction.
1872    
1873    =item toLink
1874    
1875    ID of the entity instance in the To direction.
1876    
1877    =item values
1878    
1879    Reference to a hash of other values to be used for filtering the delete.
1880    
1881    =back
1882    
1883    =cut
1884    
1885    sub DeleteRow {
1886        # Get the parameters.
1887        my ($self, $relationshipName, $fromLink, $toLink, $values) = @_;
1888        # Create a hash of all the filter information.
1889        my %filter = ('from-link' => $fromLink, 'to-link' => $toLink);
1890        if (defined $values) {
1891            for my $key (keys %{$values}) {
1892                $filter{$key} = $values->{$key};
1893            }
1894        }
1895        # Build an SQL statement out of the hash.
1896        my @filters = ();
1897        my @parms = ();
1898        for my $key (keys %filter) {
1899            push @filters, _FixName($key) . " = ?";
1900            push @parms, $filter{$key};
1901        }
1902        Trace("Parms for delete row are " . join(", ", map { "\"$_\"" } @parms) . ".") if T(SQL => 4);
1903        my $command = "DELETE FROM $relationshipName WHERE " .
1904                      join(" AND ", @filters);
1905        # Execute it.
1906        my $dbh = $self->{_dbh};
1907        $dbh->SQL($command, undef, @parms);
1908    }
1909    
1910  =head3 SortNeeded  =head3 SortNeeded
1911    
1912  C<< my $parms = $erdb->SortNeeded($relationName); >>  C<< my $parms = $erdb->SortNeeded($relationName); >>

Legend:
Removed from v.1.78  
changed lines
  Added in v.1.79

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3