[Dbix-class] Running $rs->count() on full resultset?

luke saunders luke.saunders at gmail.com
Mon Apr 10 10:21:34 CEST 2006


It's best to use a pager for this sort of thing. To get your Data::Page
object do this:
my $pager = $rs->pager;

and then to get the total page count do this:
my $total = $pager->total_entries;

http://search.cpan.org/~mstrout/DBIx-Class-0.06000/lib/DBIx/Class/Manual/Cookbook.pod#Paged_results
http://search.cpan.org/~lbrocard/Data-Page-2.00/lib/Data/Page.pm

On 4/10/06, Jesse Sheidlower <jester at panix.com> wrote:
>
>
> I'm dynamically constructing my $rs search statements, and including
> "page" and "rows" values in my attribute hash, for paged results.
>
> In my display template, I'd like to do something like "25837
> records found; displaying 50-100". However, when I call
> $rs->count() to get the count, I'm only getting the value of
> "rows" or less; that is, I get the count of my particular page
> of the resultset, rather than on the complete search. This
> despite the fact that the SQL I get from running under
> DBIX_CLASS_STORAGE_DBI_DEBUG=1 does not specify any kind of
> limit.
>
> How do I get the full count from my resultset?
>
> Jesse Sheidlower
>
> _______________________________________________
> List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
> Wiki: http://dbix-class.shadowcatsystems.co.uk/
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rawmode.org/pipermail/dbix-class/attachments/20060410/6373fbfa/attachment.htm 


More information about the Dbix-class mailing list