% 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 - A thin wrapper around qsearch argument hashes.
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.
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.
Returns another object that's a copy of this one.
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.
Runs the query and returns all results.
Runs the query and returns only one result.
Hey! The above document had some coding errors, which are explained below:
=over without closing =back