On 03/12/2014 08:54 PM, Neil Watson wrote:
Greetings,

How does pagination work? For example, I'm querying a db table that
returns hundreds of rows in a single array reference. How does that data
set get separated into separate pages?


use limit and offset. An example if you wanted to render 10 items per page is this:

my $page = 1;
my $offset = ($page - 1) * 10;
my $limit = 10;

then on your query:

SELECT * FROM atable WHERE yourquery OFFSET $offset LIMIT $limit

And presto, results for that page.

Getting the maximum number of pages left as exercise to the reader ;)

There's a couple modules on CPAN that assist in this endeavour though

--
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to