[Dbix-class] Per the design of a method

dorian taylor dorian.taylor.lists at gmail.com
Thu Jun 16 17:13:40 GMT 2011


On Thu, Jun 16, 2011 at 9:24 AM, Dan Horne <dan.horne at redbone.co.nz> 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;

    # but if I don't, this will be wrong.
    # this is where those values above would go
    while (my $rec = $rs->next) {
        # ...
    }

    # so what to do?
}

-- 
Dorian Taylor
http://doriantaylor.com/



More information about the DBIx-Class mailing list