[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.46, Thu Jun 8 19:42:06 2006 UTC revision 1.47, Sun Jun 18 05:14:56 2006 UTC
# Line 1391  Line 1391 
1391  would return the number of genomes for the genus I<homo>. It is conceivable, however,  would return the number of genomes for the genus I<homo>. It is conceivable, however,
1392  to use it to return records based on a join. For example,  to use it to return records based on a join. For example,
1393    
1394      my $count = $erdb->GetCount(['Feature', 'Genome'], 'Genome(genus-species) LIKE ?',      my $count = $erdb->GetCount(['HasFeature', 'Genome'], 'Genome(genus-species) LIKE ?',
1395                                  ['homo %']);                                  ['homo %']);
1396    
1397  would return the number of features for genomes in the genus I<homo>. Note that  would return the number of features for genomes in the genus I<homo>. Note that
# Line 1433  Line 1433 
1433      my ($self, $objectNames, $filter, $params) = @_;      my ($self, $objectNames, $filter, $params) = @_;
1434      # Declare the return variable.      # Declare the return variable.
1435      my $retVal;      my $retVal;
1436        # Find out if we're counting an entity or a relationship.
1437        my $countedField;
1438        if ($self->IsEntity($objectNames->[0])) {
1439            $countedField = "id";
1440        } else {
1441            # For a relationship we count the to-link because it's usually more
1442            # numerous. Note we're automatically converting to the SQL form
1443            # of the field name (to_link vs. to-link).
1444            $countedField = "to_link";
1445        }
1446      # Create the SQL command suffix to get the desired records.      # Create the SQL command suffix to get the desired records.
1447      my ($suffix, $mappedNameListRef, $mappedNameHashRef) = $self->_SetupSQL($objectNames,      my ($suffix, $mappedNameListRef, $mappedNameHashRef) = $self->_SetupSQL($objectNames,
1448                                                                              $filter);                                                                              $filter);
1449      # Prefix it with text telling it we want a record count.      # Prefix it with text telling it we want a record count.
1450      my $firstObject = $mappedNameListRef->[0];      my $firstObject = $mappedNameListRef->[0];
1451      my $command = "SELECT COUNT($firstObject.id) $suffix";      my $command = "SELECT COUNT($firstObject.$countedField) $suffix";
1452      # Prepare and execute the command.      # Prepare and execute the command.
1453      my $sth = $self->_GetStatementHandle($command, $params);      my $sth = $self->_GetStatementHandle($command, $params);
1454      # Get the count value.      # Get the count value.

Legend:
Removed from v.1.46  
changed lines
  Added in v.1.47

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3