dorian taylor wrote:
On Thu, Jun 16, 2011 at 9:24 AM, Dan Horne <[email protected]> wrote:
I'm not sure that I understand your query. The resultset has a Data::Page 
object which has the total number of rows, and should also handle the 
pagination for you:

Ah. Perhaps I should come clean. I'm not actually looking for
pagination but absolute offsets. I just wanted to avoid confusion but
it looks like I created it instead. The net effect though is that
Data::Page does nothing for me.

This is what I'm trying to do:

sub foo {
    my ($self, $rs, $start, $end) = @_;

    # we get absolute values one way but ResultSet wants 'em a different way
    my ($limit, $offset) = convert_to_limit_offset($start, $end);

    # if I put the limit/offset in the resultset passed in, this will be wrong
    my $total = $rs->count;

This won't be wrong - ->count returns how many objects you would receive
via ->all/->next. If you want full count of the underlying source with
all limits removed - keep the original resultset around. If you do not care
about WHERE conditions either - $rs->result_source->resultset->count will
do it for you.

Cheers

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]

Reply via email to