CPAN-Search-Lite documentation | view source
 CPAN::Search::Lite::Query - perform queries on the database


NAME

CPAN::Search::Lite::Query - perform queries on the database

__top


SYNOPSIS

  my $max_results = 200;
  my $query = CPAN::Search::Lite::Query->new(db => $db,
                                             user => $user,
                                             passwd => $passwd,
                                             max_results => $max_results);
  $query->query(mode => 'module', name => 'Net::FTP');
  my $results = $query->{results};

__top


CONSTRUCTING THE QUERY

This module queries the database via various types of queries and returns the results for subsequent display. The CPAN::Search::Lite::Query object is created via the new method as

  my $query = CPAN::Search::Lite::Query->new(db => $db,
                                             user => $user,
                                             passwd => $passwd,
                                             max_results => $max_results);

which takes as arguments

A basic query then is constructed as

   $query->query(mode => $mode, $type => $value);

with the results available as

   my $results = $query->{results}

There are four basic modes:

module, dist, and author modes

For a mode of module, dist, and author, there are four basic options to be used for the $type => $value option:

As well, for the dist mode there is an additional type: recent => $age, which will report all distribtions uploaded in the last $age days. If $age is not specified, it will default to 7.

chapter mode

For a mode of chapter, one can specify two additional arguments:

__top


RESULTS

After making the query, the results can be accessed through

  my $results = $query->{results};

No results either can mean no matches were found, or else an error in making the query resulted (in which case, a brief error message is contained in $query->{error}). Assuming there are results, what is returned depends on the mode and on the type of query. See the CPAN::Search::Lite::Populate manpage for a description of the fields in the various tables listed below - these fields are used as the keys of the hash references that arise.

author mode

module mode

dist mode

chapter mode

For a name or id query of dist, author, or module, if the query is constructed as

  $query->query(mode => $mode, $type => $value, fields => $fields);

where $fields is an array reference, then only those fields specified will be returned. For author, only the auths table is searched, for module, the mods, auths, and dists tables are searched, and for dist, the dists and auths tables are searched.

__top


SEE ALSO

Apache::CPAN::Search and Apache::CPAN::Query.

__top


COPYRIGHT

This software is copyright 2004 by Randy Kobes <randy@theoryx5.uwinnipeg.ca>. Use and redistribution are under the same terms as Perl itself.

__top

 CPAN::Search::Lite::Query - perform queries on the database

CPAN-Search-Lite documentation | view source