<% include( '/elements/header.html', 'Developer Documentation' ) %> <& /elements/menubar.html, 'Freeside Perl Modules' => $fsurl.'docs/library/FS.html', 'Complete Index' => $fsurl.'docs/library/index.html', &>

FS::Query

NAME

FS::Query - A thin wrapper around qsearch argument hashes.

DESCRIPTION

This module exists because we pass qsearch argument lists around a lot, and add new joins or WHERE expressions in several stages, and I got tired of doing this:

  my $andwhere = "mycolumn IN('perl','python','javascript')";
  if ( ($search->{hashref} and keys( %{$search->{hashref}} ))
       or $search->{extra_sql} =~ /^\s*WHERE/ ) {
    $search->{extra_sql} .= " AND $andwhere";
  } else {
    $search->{extra_sql} = " WHERE $andwhere ";
  }

and then having it fail under some conditions if it's done wrong (as the above example is, obviously).

We may eventually switch over to SQL::Abstract or something for this, but for now it's a couple of crude manipulations and a wrapper to qsearch.

METHODS

new HASHREF

Turns HASHREF (a qsearch argument list) into an FS::Query object. None of the params are really required, but you should at least supply table.

In the Future this may do a lot more stuff.

clone

Returns another object that's a copy of this one.

and_where EXPR

Adds a constraint to the WHERE clause of the query. All other constraints in the WHERE clause should be joined with AND already; if not, they should be grouped with parentheses.

qsearch

Runs the query and returns all results.

qsearchs

Runs the query and returns only one result.

POD ERRORS

Hey! The above document had some coding errors, which are explained below:

Around line 33:

=over without closing =back

<% include ('/elements/footer.html' ) %>