Bio::DB::Query DBQueryResult
SummaryIncluded librariesPackage variablesSynopsisDescriptionGeneral documentationMethods
Bio::DB::Query::DBQueryResult - DESCRIPTION of Object
Package variables
No package variables defined.
Included modules
Bio::DB::Query::QueryResultI Bio::Root::Root
Give standard usage here
This modules provides an implementation of Bio::DB::Query::QueryResultI for
database queries through DBI.
Methods description
newcode    nextTop
 Title   : new
Usage : my $obj = Bio::DB::Query::DBQueryResult->new();
Function: Builds a new Bio::DB::Query::DBQueryResult object
Returns : an instance of Bio::DB::Query::DBQueryResult
Args : named parameters
-sth the statement handle (this object will not execute it) -adaptor the persistence adaptor (basically needs to implement instantiate_from_row($row, $factory) -factory optionally, the object factory to pass to the adaptor -num_fks the number of foreign key object columns in the rows -flat_only whether to retrieve and attach children when building objects (default: false) If none of these are given at instantiation, at least sth() and persistence_adaptor() must be set prior to calling next_object().
 Title   : next_object
Usage :
Function: Obtain the next object from the result stream and return it.
Example :
Returns : A Bioperl object (implementing at least Bio::Root::RootI)
Args : none
 Title   : each_Object
Usage :
Function: This is primarily a convenience method and in most implementations
will just loop over next_object() and return an array of all
Example :
Returns : A reference to an array of objects.
Args : Optionally, an anonymous function for filtering objects. If given,
the function is passed one argument, the object to evaluate.
The object will be included in the returned array if the function
returns TRUE, and rejected otherwise.
 Title   : finish
Usage :
Function: Indicate being finished with this result so that possibly used
system resources can be released.
Example :
Returns : none
Args : none
 Title   : sth
Usage : $obj->sth($newval)
Function: Get/set statement handle from which to fetch the next row.
This can be changed at any time. If changed, it means the next call to next_object() will fetch from the new handle. Also, the caller needs to finish() the previous handle if necessary (i.e., if not exhausted). Note that this object will not execute the statement handle. The caller needs to ensure that has been happened until next_object() is called. Example : Returns : value of sth (a DBI statement handle) Args : new value (a DBI statement handle, optional)
 Title   : persistence_adaptor
Usage : $obj->persistence_adaptor($newval)
Function: Get/set the instantiation adaptor to which to delegate object
instantiation from an array of row values.
The adaptor can be any object that implements instantiate_from_row() with two arguments, a reference to an array of column values, and optionally an object factory. This can be changed at any time with no adverse side effect other than the kind of object built possibly changing. Example : Returns : value of persistence_adaptor (an object) Args : new value (an object, optional)
 Title   : object_factory
Usage : $obj->object_factory($newval)
Function: Get/set the object factory to pass to the instantiation adaptor.
Setting this is optional because providing it to the instantiation adaptor is optional. Example : Returns : value of object_factory (a Bio::Factory::ObjectFactoryI compliant instance) Args : new value (a Bio::Factory::ObjectFactoryI compliant instance, optional)
 Title   : num_fks
Usage : $obj->num_fks($newval)
Function: Get/set the number of foreign key columns in a given result row.
Setting this correctly is only important for query results for which the resulting objects must have the foreign key objects attached. Example : Returns : value of num_fks (a scalar) Args : new value (a scalar, optional)
 Title   : flat_retrieval
Usage : $obj->flat_retrieval($newval)
Function: Get/set whether objects should be retrieved and built flat
or with all their dependent objects fetched and attached.
The default is to build full objects with all children attached which provides for no bad surprises when inspecting the results. However, building flat objects by disregarding children is potentially a lot faster, so this option is useful if, for instance, for a sequence you don't need any annotation or features. Example : Returns : value of flat_retrieval (a scalar evaluating to true or false) Args : on set, new value (a scalar or undef, optional)
Methods code
sub new {
    my($class,@args) = @_;

    my $self = $class->SUPER::new(@args);
    my ($sth, $adaptor, $fact, $nfks, $flatonly) =
	$self->_rearrange([qw(STH ADAPTOR FACTORY NUM_FKS FLAT_ONLY)], @args);
    $self->sth($sth) if $sth;
    $self->persistence_adaptor($adaptor) if $adaptor;
    $self->object_factory($fact) if $fact;
    $self->num_fks($nfks) if defined($nfks);

    return $self;
sub next_object {
    my ($self) = @_;
    my $obj;

    my $row = $self->sth()->fetchrow_arrayref();
    if($row) {
	my $adp = $self->persistence_adaptor();
	# build the object
$obj = $adp->_build_object(-row => $row, -obj_factory => $self->object_factory(), -num_fks => $self->num_fks(), -flat_only => $self->flat_retrieval()); } return $obj;
sub each_Object {
    my ($self,$filter) = @_;
    my @objs = ();

    while(my $obj = $self->next_object()) {
	if((! $filter) || &$filter($obj)) {
	    push(@objs, $obj);
    return\@ objs;
sub finish {
    my $self = shift;
    $self->sth()->finish() if $self->sth();
sub sth {
    my ($self,$value) = @_;
    if( defined $value) {
	$self->{'sth'} = $value;
    return $self->{'sth'};
sub persistence_adaptor {
    my ($self,$value) = @_;
    if( defined $value) {
	$self->{'adp'} = $value;
    return $self->{'adp'};
sub object_factory {
    my ($self,$value) = @_;
    if( defined $value) {
	$self->{'object_factory'} = $value;
    return $self->{'object_factory'};
sub num_fks {
    my ($self,$value) = @_;
    if( defined $value) {
	$self->{'num_fks'} = $value;
    return $self->{'num_fks'};
sub flat_retrieval {
    my $self = shift;

    return $self->{'flat_retrieval'} = shift if @_;
    return $self->{'flat_retrieval'};

General documentation
Mailing ListsTop
User feedback is an integral part of the evolution of this and other
Bioperl modules. Send your comments and suggestions preferably to
the Bioperl mailing list. Your participation is much appreciated.                  - General discussion - About the mailing lists
Support Top
Please direct usage questions or support issues to the mailing list:

rather than to the module maintainer directly. Many experienced and
reponsive experts will be able look at the problem and quickly
address it. Please include a thorough description of the problem
with code and data examples if at all possible.
Reporting BugsTop
Report bugs to the Bioperl bug tracking system to help us keep track
of the bugs and their resolution. Bug reports can be submitted via
the web:
AUTHOR - Hilmar LappTop
Email hlapp at
Describe contact details here
Additional contributors names and emails here
The rest of the documentation details each of the object methods.
Internal methods are usually preceded with a _