NAME
DBIx::SQLEngine::RecordSet::Set - Array of Record Objects
SYNOPSIS
use DBIx::SQLEngine::RecordSet::Set;
$record_set = DBIx::SQLEngine::RecordSet::Set->new( @records );
$record_set = $record_class->fetch_select( criteria => { status => 2 } );
print "Found " . $record_set->count() . " records";
$record_set->filter( { 'status' => 'New' } );
$record_set->sort( 'creation_date' );
foreach ( 0 .. $record_set->count() ) {
print $record_set->record( $_ )->name();
}
foreach ( $record_set->range_records( 11, 20 ) ) {
print $_->name();
}
DESCRIPTION
This package is not yet complete.
The base implementation of RecordSet is an array of Record references.
Constructor
- new()
-
$class->new ( @records ) : $recordset
Array constructor.
- clone()
-
$recordset->clone() : $recordset
Create a shallow copy of the record set.
Contents
- init()
-
$recordset->init ( @records )
Array content setter.
- records()
-
$rs->records() : @records
Array content accessor.
Positional Access
- count()
-
$count = $rs->count();
Returns the number of records in this set.
- record()
-
$record = $rs->record( $position );
Return the record in the indicated position in the array. Returns nothing if position is undefined.
Indexes start with zero. Negative indexes are counted back from the end, with -1 being the last, -2 being the one before that, and so forth.
- last_record
-
$record = $rs->last_record();
Return the last record in the array.
Positional Subsets
- range_set()
-
$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.
- range_records()
-
@records = $rs->range_records( $start_pos, $stop_pos );
Return the records at or between the start and stop positions.
Sorting
Use of these methods requires the Data::Sorting module from CPAN.
See Data::Sorting for more information.
- sort()
-
$rs->sort( @fieldnames );
Sort the contents of the set.
- sorted_set()
-
$clone = $rs->sorted_set( @fieldnames );
Return a sorted copy of the current set.
- sorted_records()
-
@records = $rs->sorted_records( @fieldnames );
Return the records from the current set, in sorted order.
Criteria Matching
Caution: This set of methods is currently not working.
- filter()
-
$rs->filter( $criteria );
Remove non-matching records from the set.
- filtered_set()
-
$clone = $rs->filtered_set( $criteria );
Return a set containing only the matching records from the current set.
- filtered_records()
-
@records = $rs->filtered_records( $criteria );
Return the matching records from the current set.
SEE ALSO
See DBIx::SQLEngine for the overall interface and developer documentation.
See DBIx::SQLEngine::Docs::ReadMe for general information about this distribution, including installation and license information.