PHP (or ASP) Boolean to SQL Query Translator
Description:
This is a set of PHP functions that convert boolean syntax (such as "dogs" and "cats" not "mammoth") into SQL statements that can be run as a database query. I didn't do much in the way of sanitization here, any programmer using this is expected to sanitize his input before feeding it to this function. No excuses.
Update: This script has now been translated to work under ASP as well. Thanks to the user who goaded me into finally getting that done, I had intended to it years ago. The ASP version hasn't been tested as thoroughly as the PHP version, but appears to be outputting identical output for a given input. Source is at the bottom of the page.
Usage:
bq_simple ($return_fields, $tables, $check_fields, $query_text);
"$return_fields" is a space delineated list of the fields you would like the query to return
"$tables" is a space delineated list of the tables names to search
"$check_fields" is a space delineated list of the fields within those tables to search for the arguments in
"$query_text" is the boolean query itself (what the user typed in the search box)
The return value is a full SQL statement that can then be run against the database.