The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

DBIx::StORM::RecordSet

DESCRIPTION

This represents a set of results (rows) from the database. There are a few methods here to manipulate the rows as a group, but conveniently a RecordSet behaves like an array reference, so by doing so you can foreach() over it or look up rows by index. You should not create RecordSets directly, but instead obtain them from a DBIx::StORM connection using the table methods.

METHODS

$instance->grep(sub { })

Filter the result set, returning a new RecordSet. The subroutine will be called once for each row in the RecordSet with $_ set to the DBIx::StORM::Record object. If the subroutine returns a true value the Record will be added to the return RecordSet. $instance is not modified.

$instance->lookup(field)

Return the value of field from the first result in the set. Shorthand for $instance->[0]->_get(field)

$instance->update(sub { })

For each Record in the RecordSet, the subroutine is executed with $_ set to the Record. The subroutine is allowed to alter the fields of $_, and the changes will be written back to the database.

$instance->delete()

The Records in the RecordSet will all be invalidated and then removed from the database.

EXAMPLE

 foreach my $result (@$resultset) {
   print "In row ", $result->id, " the total price is ",
     $result->total, ".\n";
 }