Here is another approach I was actually just working on.
<?php
if ($_GET["display"] == "tags") {
$_GET["searchTags"] = true;
$searchTerm_tagSearch = "-1";
if (isset($params[0])) {
$searchTerm_tagSearch = $params[0];
}
mysql_select_db($database_blog, $blog);
$query_tagSearch = sprintf("SELECT GROUP_CONCAT(blog_tags2posts.idPost SEPARATOR ', ') AS tagSearch FROM blog_tags2Posts INNER JOIN blog_tags ON blog_tags.id = blog_tags2Posts.idTag WHERE blog_tags.tag = %s", GetSQLValueString($searchTerm_tagSearch, "text"));
$tagSearch = mysql_query($query_tagSearch, $blog) or die(mysql_error());
$row_tagSearch = mysql_fetch_assoc($tagSearch);
$totalRows_tagSearch = mysql_num_rows($tagSearch);
$_GET["search"] = $row_tagSearch['tagSearch'];
}
?>
<?php
//WA Database Search (Copyright 2005, WebAssist.com)
//Recordset: blogPosts;
//Searchpage: ;
//Form: ;
$WADbSearch1_DefaultWhere = "";
if (!session_id()) session_start();
if ((isset($_GET['searchTags']) && $_GET['searchTags'] != "")) {
$WADbSearch1 = new FilterDef;
$WADbSearch1->initializeQueryBuilder("MYSQL","1");
//keyword array declarations
//comparison list additions
$WADbSearch1->addComparisonFromList("id","search","OR","=",1);
//save the query in a session variable
if (1 == 1) {
$_SESSION["WADbSearch1_blog"]=$WADbSearch1->whereClause;
}
}
else {
$WADbSearch1 = new FilterDef;
$WADbSearch1->initializeQueryBuilder("MYSQL","1");
//get the filter definition from a session variable
if (1 == 1) {
if (isset($_SESSION["WADbSearch1_blog"]) && $_SESSION["WADbSearch1_blog"] != "") {
$WADbSearch1->whereClause = $_SESSION["WADbSearch1_blog"];
}
else {
$WADbSearch1->whereClause = $WADbSearch1_DefaultWhere;
}
}
else {
$WADbSearch1->whereClause = $WADbSearch1_DefaultWhere;
}
}
$WADbSearch1->whereClause = str_replace("\\''", "''", $WADbSearch1->whereClause);
$WADbSearch1whereClause = '';
?>
GROUP_CONCAT is used to "implode" all the idPost values from the relational table. Notice the SEPARATOR has to be assigned ", " because that is the separator WA (notice the space after the comma which is not default for the GROUP_CONCAT function).
Then the WADB search behavior is applied. Since I use the url variable display for multiple purposes, I have to specify a separate trigger variable (STILL WISH WE COULD USE EXPRESSIONS AS TRIGGERS). Then a different variable is used for the list of ID's. The GUI field type in the server behavior is list and the separator is OR.
I also noticed that the help file says if more than one WADB Search behavior is used, a default WHERE clause must be specified. I used this approach twice. Once for tags and another for categories. Since the value of display ensures only one recordset of comma separated id's to pull is created, it is important, in this case, to NOT to specify a default WHERE clause or it doesn't work because you end up with a WHERE clause like: WHERE 0=0 OR ((id = 32) OR (id = 47)) which still pulls all the records.
I don't think this can be used for a natural language search . Can it?