DBIx::Class::Manual::Cookbook

DBIx::Class::Manual::Cookbook is a Perl module that contains miscellaneous recipes.
Download

DBIx::Class::Manual::Cookbook Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Matt S. Trout
  • Publisher web site:
  • http://search.cpan.org/~mstrout/DBIx-Class-0.08001/lib/DBIx/Class/Manual/Cookbook.pod

DBIx::Class::Manual::Cookbook Tags


DBIx::Class::Manual::Cookbook Description

DBIx::Class::Manual::Cookbook is a Perl module that contains miscellaneous recipes. DBIx::Class::Manual::Cookbook is a Perl module that contains miscellaneous recipes.Paged resultsWhen you expect a large number of results, you can ask DBIx::Class for a paged resultset, which will fetch only a small number of records at a time: my $rs = $schema->resultset('Artist')->search( undef, { page => 1, # page to return (defaults to 1) rows => 10, # number of results per page }, ); return $rs->all(); # all records for page 1The page attribute does not have to be specified in your search: my $rs = $schema->resultset('Artist')->search( undef, { rows => 10, } ); return $rs->page(1); # DBIx::Class::ResultSet containing first 10 recordsIn either of the above cases, you can return a Data::Page object for the resultset (suitable for use in e.g. a template) using the pager method: return $rs->pager();Complex WHERE clausesSometimes you need to formulate a query using specific operators: my @albums = $schema->resultset('Album')->search({ artist => { 'like', '%Lamb%' }, title => { 'like', 'ar of Fours%' }, });This results in something like the following WHERE clause: WHERE artist LIKE '%Lamb%' AND title LIKE 'ar of Fours%'Other queries might require slightly more complex logic: my @albums = $schema->resultset('Album')->search({ -or => , artist => 'Starchildren', ], });This results in the following WHERE clause: WHERE ( artist LIKE '%Smashing Pumpkins%' AND title = 'Siamese Dream' ) OR artist = 'Starchildren'For more information on generating complex queries, see "WHERE CLAUSES" in SQL::Abstract. Requirements: · Perl


DBIx::Class::Manual::Cookbook Related Software