predicate => 'has_page',
);
+=attribute_public offset is ro, isa: Int
+
+offset specifies where to start the paged result (think SQL LIMIT)
+
+=cut
+
+ has 'offset' =>
+ (
+ is => 'ro',
+ writer => '_set_offset',
+ isa => Int,
+ predicate => 'has_offset',
+ );
+
=attribute_public ordered_by is: ro, isa: L<Catalyst::Controller::DBIC::API::Types/OrderedBy>
ordered_by is passed to ->search to determine sorting
$self->_set_as($new->{$controller->as_arg}) if exists $new->{$controller->as_arg};
$self->_set_grouped_by($new->{$controller->grouped_by_arg}) if exists $new->{$controller->grouped_by_arg};
$self->_set_ordered_by($new->{$controller->ordered_by_arg}) if exists $new->{$controller->ordered_by_arg};
- $self->_set_search($new->{$controller->search_arg}) if exists $new->{$controller->search_arg};
$self->_set_count($new->{$controller->count_arg}) if exists $new->{$controller->count_arg};
$self->_set_page($new->{$controller->page_arg}) if exists $new->{$controller->page_arg};
+ $self->_set_offset($new->{$controller->offset_arg}) if exists $new->{$controller->offset_arg};
+ $self->_set_search($new->{$controller->search_arg}) if exists $new->{$controller->search_arg};
}
);
method format_search_parameters => sub
{
- $DB::single = 1;
my ($self, $params) = @_;
my $genparams = [];
method generate_column_parameters => sub
{
- $DB::single = 1;
my ($self, $source, $param, $join, $base) = @_;
$base ||= 'me';
my $search_params;
method generate_parameters_attributes => sub
{
- $DB::single = 1;
my ($self, $args) = @_;
return ( $self->format_search_parameters($args), $self->search_attributes );
as => $self->as || ((scalar(@{$static->as})) ? $static->as : undef),
prefetch => $self->prefetch || $static->prefetch || undef,
rows => $self->count || $static->count,
- page => $self->page,
+ offset => $self->offset,
join => $self->build_joins,
};
+ if($self->has_page)
+ {
+ $search_attributes->{page} = $self->page;
+ }
+ elsif(!$self->has_page && defined($search_attributes->{offset}) && defined($search_attributes->{rows}))
+ {
+ $search_attributes->{page} = $search_attributes->{offset} / $search_attributes->{rows} + 1;
+ delete $search_attributes->{offset};
+ }
+
+
$search_attributes =
{
map { @$_ }