This is not a tutorial but the way I would recommend doing it; from DBIx::Class::Manual::Cookbook which is part of DBIx::Class-

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 1 return $rs->page(2); # records for page 2

Probably most of the monks here who do webdev have written paging code from scratch at least once. It's not particularly hard but it *is* messy with a lot of off-by-one accounting and tracking of parameters. The paging code used above -- which uses Data::Page -- gives you a clean interface through the mess.

DBIx::Class has a steep learning curve. You have to decide if it's worth it but while making the decision in the midst of painful first attempts keep in mind that without some kind of formal framework or rigor in the code, you are highly likely to get insecure DB interactions and rewrite things that will be extremely difficult and time-consuming for a beginner that are simple functions/methods in DBIC, etc. DBIC has a somewhat rough talking IRC channel but they do give expert help for free.


In reply to Re: How to do Pagination With Perl and mySQL by Your Mother
in thread How to do Pagination With Perl and mySQL by maicon1121

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.