Terrence Brannon


DBIx::Cookbook::Recipe::Searching::predefined_search - predefined searches


As a function of the options rows and page, output the results of the query

  SELECT * FROM actor ORDER BY last_name

The rows option specifies how many rows per page. The page option specifies which page of the resultset to start with. For example, if there are 20 rows in the resultset and rows has been set to 4, then there will be 5 pages. The pages option will specify from which page results should be listed, with any number from 1 to 5 being acceptable.

Sample Usage:

  shell> ${orm}_cmd predefined_search  # orm = dbic, skinny, rose, etc



    package DBIx::Cookbook::DBIC::Command::predefined_search;
    use Moose;
    extends qw(MooseX::App::Cmd::Command);
    use Data::Dump;
    has 'starts_with' => (
               traits => [qw(Getopt)],
               isa => "Str",
               is  => "rw",
               documentation => "first letter(s) that country starts with"
    has 'max_id' => (
               traits => [qw(Getopt)],
               isa => "Int",
               is  => "rw",
               documentation => "maximum acceptable id"
    sub execute {
      my ($self, $opt, $args) = @_;
      my $rs = $self->app->schema->resultset('Country')->search_country
        ($opt->{starts_with}, $opt->{max_id});
      while (my $row = $rs->next) {
          use Data::Dump qw(dump);
          my %data = $row->get_columns;
          warn dump(\%data);