[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.6, Wed May 4 03:24:43 2005 UTC revision 1.7, Thu May 5 03:14:03 2005 UTC
# Line 753  Line 753 
753  specified filter clause.  specified filter clause.
754    
755  This method is essentially the same as L</Get> except it returns a list of objects rather  This method is essentially the same as L</Get> except it returns a list of objects rather
756  that a query object that can be used to get the results one record at a time.  than a query object that can be used to get the results one record at a time.
   
 =over 4  
757    
758  =over 4  =over 4
759    
# Line 1279  Line 1277 
1277          return @retVal;          return @retVal;
1278  }  }
1279    
1280    =head3 GetAll
1281    
1282    C<< my @list = $sprout->GetAll(\@objectNames, $filterClause, \@parameters, \@fields, $count); >>
1283    
1284    Return a list of values taken from the objects returned by a query. The first three
1285    parameters correspond to the parameters of the L</Get> method. The final parameter is
1286    a list of the fields desired from each record found by the query. The field name
1287    syntax is the standard syntax used for fields in the B<ERDB> system--
1288    B<I<objectName>(I<fieldName>)>-- where I<objectName> is the name of the relevant entity
1289    or relationship and I<fieldName> is the name of the field.
1290    
1291    The list returned will be a list of lists. Each element of the list will contain
1292    the values returned for the fields specified in the fourth parameter. If one of the
1293    fields specified returns multiple values, they are flattened in with the rest. For
1294    example, the following call will return a list of the features in a particular
1295    spreadsheet cell, and each feature will be represented by a list containing the
1296    feature ID followed by all of its aliases.
1297    
1298    C<< $query = $sprout->Get(['ContainsFeature', 'Feature'], "ContainsFeature(from-link) = ?", [$ssCellID], ['Feature(id)', 'Feature(alias)']); >>
1299    
1300    =over 4
1301    
1302    =item objectNames
1303    
1304    List containing the names of the entity and relationship objects to be retrieved.
1305    
1306    =item filterClause
1307    
1308    WHERE/ORDER BY clause (without the WHERE) to be used to filter and sort the query. The WHERE clause can
1309    be parameterized with parameter markers (C<?>). Each field used must be specified in the standard form
1310    B<I<objectName>(I<fieldName>)>. Any parameters specified in the filter clause should be added to the
1311    parameter list as additional parameters. The fields in a filter clause can come from primary
1312    entity relations, relationship relations, or secondary entity relations; however, all of the
1313    entities and relationships involved must be included in the list of object names.
1314    
1315    =item parameterList
1316    
1317    List of the parameters to be substituted in for the parameters marks in the filter clause.
1318    
1319    =item fields
1320    
1321    List of the fields to be returned in each element of the list returned.
1322    
1323    =item count
1324    
1325    Maximum number of records to return. If omitted or 0, all available records will be returned.
1326    
1327    =item RETURN
1328    
1329    Returns a list of list references. Each element of the return list contains the values for the
1330    fields specified in the B<fields> parameter.
1331    
1332    =back
1333    
1334    =cut
1335    #: Return Type @@;
1336    sub GetAll {
1337            # Get the parameters.
1338            my ($self, $objectNames, $filterClause, $parameterList, $fields, $count) = @_;
1339            # Translate the parameters from a list reference to a list. If the parameter
1340            # list is a scalar we convert it into a singleton list.
1341            my @parmList = ();
1342            if (ref $parameterList eq "ARRAY") {
1343                    @parmList = @{$parameterList};
1344            } else {
1345                    push @parmList, $parameterList;
1346            }
1347            # Create the query.
1348            my $query = $self->Get($objectNames, $filterClause, @parmList);
1349            # Set up a counter of the number of records read.
1350            my $fetched = 0;
1351            # Insure the counter has a value.
1352            if (!defined $count) {
1353                    $count = 0;
1354            }
1355            # Loop through the records returned, extracting the fields. Note that if the
1356            # counter is non-zero, we stop when the number of records read hits the count.
1357            my @retVal = ();
1358            while (($count == 0 || $fetched < $count) && (my $row = $query->Fetch())) {
1359                    my @rowData = $row->Values($fields);
1360                    push @retVal, \@rowData;
1361                    $fetched++;
1362            }
1363            # Return the resulting list.
1364            return @retVal;
1365    }
1366    
1367  =head2 Internal Utility Methods  =head2 Internal Utility Methods
1368    
1369  =head3 GetLoadStats  =head3 GetLoadStats

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3