# Class::DBI::Search::Basic - perldoc - [phpMan]

## NAME
    [Class::DBI::Search::Basic](https://www.chedong.com/phpMan.php/perldoc/Class%3A%3ADBI%3A%3ASearch%3A%3ABasic/markdown) - Simple [Class::DBI](https://www.chedong.com/phpMan.php/perldoc/Class%3A%3ADBI/markdown) search

## SYNOPSIS
            my $searcher = [Class::DBI::Search::Basic](https://www.chedong.com/phpMan.php/perldoc/Class%3A%3ADBI%3A%3ASearch%3A%3ABasic/markdown)->new(
                    $cdbi_class, @search_args
            );

            my @results = $searcher->run_search;

            # Over in your [Class::DBI](https://www.chedong.com/phpMan.php/perldoc/Class%3A%3ADBI/markdown) subclass:

            __PACKAGE__->add_searcher(
                    search  => "[Class::DBI::Search::Basic](https://www.chedong.com/phpMan.php/perldoc/Class%3A%3ADBI%3A%3ASearch%3A%3ABasic/markdown)",
              isearch => "[Class::DBI::Search::Plugin::CaseInsensitive](https://www.chedong.com/phpMan.php/perldoc/Class%3A%3ADBI%3A%3ASearch%3A%3APlugin%3A%3ACaseInsensitive/markdown)",
            );

## DESCRIPTION
    This is the start of a pluggable Search infrastructure for [Class::DBI](https://www.chedong.com/phpMan.php/perldoc/Class%3A%3ADBI/markdown).

    At the minute [Class::DBI::Search::Basic](https://www.chedong.com/phpMan.php/perldoc/Class%3A%3ADBI%3A%3ASearch%3A%3ABasic/markdown) doubles up as both the default search within [Class::DBI](https://www.chedong.com/phpMan.php/perldoc/Class%3A%3ADBI/markdown)
    as well as the search base class. We will probably need to tease this apart more later and
    create an abstract base class for search plugins.

## METHODS
  new
            my $searcher = [Class::DBI::Search::Basic](https://www.chedong.com/phpMan.php/perldoc/Class%3A%3ADBI%3A%3ASearch%3A%3ABasic/markdown)->new(
                    $cdbi_class, @search_args
            );

    A Searcher is created with the class to which the results will belong, and the arguments passed
    to the search call by the user.

  opt
            if (my $order = $self->opt('order_by')) { ... }

    The arguments passed to search may contain an options hash. This will return the value of a
    given option.

  run_search
            my @results = $searcher->run_search;
            my $iterator = $searcher->run_search;

    Actually run the search.

## SUBCLASSING
  sql / bind / fragment
    The actual mechanics of generating the SQL and executing it split up into a variety of methods
    for you to override.

### run_search

      return $cdbi->sth_to_objects($self->sql, $self->bind);

    Where sql() is

      $cdbi->sql_Retrieve($self->fragment);

    There are also a variety of private methods underneath this that could be overridden in a pinch,
    but if you need to do this I'd rather you let me know so that I can make them public, or at
    least so that I don't remove them from under your feet.

