[Dbix-class] Pager offset not implemented?

Matt S Trout dbix-class at trout.me.uk
Mon Nov 21 18:10:33 CET 2005


On Mon, Nov 21, 2005 at 04:06:55PM +0000, Nigel Metheringham wrote:
> In the documentation for DBIX::Class::Recordset (version
> DBIx-Class-0.03003), the offset search attribute is stated as selecting
> the initial page returned of a paged result set.
> 
> That doesn't seem to work when I try it in my code - instead I need to
> do:-
>         my $items = $class->search({},
>                                    {page		=> 1,
>                                     rows		=> 20});
>         $items = $items->page($c->request->param('page'))
>             if ($c->request->param('page') > 1);
> 
> It also looks like the ResultSet pager method deletes out the offset
> attribute...

I suspect that's a bug; I'll look into it.
 
> Is this method officially not implemented at the moment?

It is, it's just misdocumented - page is meant to be the page number :)

Correct usage would be -

my $page = $c->request->param('page') || 1;
my $items = $class->search({}, { page => $page, rows => 20 });

(offset is designed to get e.g. records 30-50 via { offset => 30, rows => 20 })

-- 
     Matt S Trout       Specialists in Perl consulting, web development, and
  Technical Director    UNIX/Linux systems architecture and automation. Mail
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

 + Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +



More information about the Dbix-class mailing list