[Dbix-class] Pagination Troubles
fREW Schmidt
frioux at gmail.com
Thu Feb 5 18:43:58 GMT 2009
Hi all!
I am trying to paginate some results and I need to get the count of the full
results. I tried to use count and that only gives the amount that are in
the current result set. I tried to do this:
http://lists.scsys.co.uk/pipermail/dbix-class/2006-April/001204.html But
got errors about trying to call pager on non-paged data. Here is my code:
sub basic_data {
> my $self =3D shift;
> my $params =3D shift;
>
> my $table =3D $params->{table};
> my $search =3D $params->{search};
> my $columns =3D $params->{columns};
>
> use DBIx::Class::ResultClass::HashRefInflator;
>
> my $rs =3D $self->schema()->resultset($table)->search($search,{
> rows =3D> $self->query->param('limit') || 25,
> order_by =3D> $self->query->param('sort')."
> ".$self->query->param('dir') || 'id',
> columns =3D> $columns
> });
>
> $rs->result_class('DBIx::Class::ResultClass::HashRefInflator');
>
> my $data =3D { data =3D> []};
>
> while (my $operation_code =3D $rs->next() ) {
> push @{$data->{data}}, $operation_code;
> }
> $data->{total} =3D $rs->count;
>
> return $self->json_body($data);
> }
>
Can anyone tell me what I should be doing?
-- =
fREW Schmidt
http://blog.afoolishmanifesto.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20090205/222=
b47f3/attachment.htm
More information about the DBIx-Class
mailing list