Class-DBI-Search-LIMITed

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

METHODS
  add_searcher
            __PACKAGE__->add_searcher(
                    method_name => 'Class::DBI::Search::LIMITed'
            );

    As with all Search plugins you can choose the method name for the search
    that it generates. You can either make a distinct limit-ed search method
    (e.g. search_limited()), or just make it your default search() method.

  fragment
    This overrides the default 'fragment' method in
    Class::DBI::Search::Basic to add any 'limit' option passed in your
    search query.

CAVEATS
    This is only useful for databases which support a LIMIT modifier, such
    as MySQL.

AUTHOR
    Tony Bowden

lib/Class/DBI/Search/LIMITed.pm  view on Meta::CPAN

package Class::DBI::Search::LIMITed;

our $VERSION = '1.01';

use strict;
use warnings;

use base 'Class::DBI::Search::Basic';

sub fragment {
  my $self = shift;
  my $frag = $self->SUPER::fragment;
  if (defined(my $limit = $self->opt('limit'))) {
    $frag .= " LIMIT $limit";
  }
  return $frag;
}

1;

__END__

=head1 NAME

Class::DBI::Search::LIMITed - add 'LIMIT' to Class::DBI searches

lib/Class/DBI/Search/LIMITed.pm  view on Meta::CPAN

=head2 add_searcher

	__PACKAGE__->add_searcher(
		method_name => 'Class::DBI::Search::LIMITed'
	);

As with all Search plugins you can choose the method name for the search
that it generates. You can either make a distinct limit-ed search method
(e.g. search_limited()), or just make it your default search() method.

=head2 fragment

This overrides the default 'fragment' method in Class::DBI::Search::Basic
to add any 'limit' option passed in your search query.

=head1 CAVEATS

This is only useful for databases which support a LIMIT modifier, such
as MySQL. 

=head1 AUTHOR

Tony Bowden



( run in 1.618 second using v1.01-cache-2.11-cpan-364913b4093 )