Skip to content

Commit

Permalink
ResultSetManager example from CaptainCarlos
Browse files Browse the repository at this point in the history
  • Loading branch information
castaway committed Mar 29, 2006
1 parent 1268518 commit d6ed6a6
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions lib/DBIx/Class/Manual/Cookbook.pod
Expand Up @@ -200,6 +200,26 @@ Then call your new method in your code:
my $ordered_cds = $schema->resultset('CD')->search_cds_ordered();


=head3 Predefined searches without writing a ResultSet class

Alternatively you can automatically generate a DBIx::Class::ResultSet
class by using the ResultSetManager component and tagging your method
as ResultSet:

__PACKAGE__->load_components(qw/ ResultSetManager Core /);

sub search_cds_ordered : ResultSet {
my ($self) = @_;
return $self->search(
{},
{ order_by => 'name DESC' },
);
}

Then call your method in the same way from your code:

my $ordered_cds = $schema->resultset('CD')->search_cds_ordered();

=head2 Using joins and prefetch

You can use the C<join> attribute to allow searching on, or sorting your
Expand Down

0 comments on commit d6ed6a6

Please sign in to comment.