NAME
DBIx::DBO2::RecordSet - A sequential group of Record objects
SYNOPSIS
$rs = DBIx::DBO2::RecordSet->new( @records );
print "Found " . $rs->count() . " records";
$rs->filter( { 'status' => 'New' } );
$rs->sort( 'creation_date' );
foreach ( 0 .. $rs->count() ) {
print $rs->record( $_ )->name();
}
foreach ( $rs->range_records( 11, 20 ) ) {
print $_->name();
}
DESCRIPTION
The base implementation of RecordSet is an array of Record references.
Constructor:
Basics
$rs = DBIx::DBO2::RecordSet->new( @records );
Create a new RecordSet.
$rs->init( @records );
@records = $rs->records();
Class and IDs
$rs = DBIx::DBO2::RecordSet->new_class_ids( $class, @ids );
$rs->init_class_ids( $class, @ids );
( $class, @ids ) = $rs->class_ids();
Conversions
Each of the below returns a RecordSet blessed into a particular subclass. Returns the original object if it is already of that subclass, or returns a cloned and converted copy.
@data = $rs->raw();
Returns the contents of the RecordSet as stored internally within the object. Results are dependent on which subclass is in use.
$rs = $rs->as_RecordArray;
INCOMPLETE
$clone = $rs->as_IDArray;
INCOMPLETE
$clone = $rs->as_IDString;
INCOMPLETE
Positional Access
$count = $rs->count();
$record = $rs->record( $position );
Return the record in the indicated position in the array.
$record = $rs->last_record();
Return the last record in the array.
$clone = $rs->range_set( $start_pos, $stop_pos );
Return a copy of the current set containing only those records at or between the start and stop positions.
@records = $rs->range_records( $start_pos, $stop_pos );
Return the records at or between the start and stop positions.
Sorting
$rs->sort( @fieldnames );
Sort the contents of the set.
$clone = $rs->sorted_set( @fieldnames );
Return a sorted copy of the current set.
@records = $rs->sorted_records( @fieldnames );
Return the records from the current set, in sorted order.
Criteria Matching
$rs->filter( $criteria );
Remove non-matching records from the set.
$clone = $rs->filtered_set( $criteria );
Return a set containing only the matching records from the current set.
@records = $rs->filtered_records( $criteria );
Return the matching records from the current set.
CHANGES
2001-06-29 Moved to DBIx::DBO2 namespace.
2001-04-10 Added last_record.
2000-12-13 Substantial revisions. Moved to EBiz::Database namespace.
2000-12-01 Ed: Created.