Theatre Australia

your portal for australian theatre

DGSSearch

Tue, 10 Feb 2004, 05:54 am
Walter Plinge6 posts in thread
Hey guys,

I did a Google search for the term "dgssearch modification" and your site was listed third. I'm using dgssearch as the basis of a site I'm building and noticed that it doesn't support boolean searches (e.g. nissan and maxima). You guys appear to have modified the base code to support this kind of search.

I might be out of line in asking, but what the hell. Would you mind sharing the modified search code? I'm fairly new to php coding and this would save me a bunch of time.

Thanks for the consideration.

Mark Russell
www.findingautos.com

Thread (6 posts)

Walter PlingeTue, 10 Feb 2004, 05:54 am
Hey guys,

I did a Google search for the term "dgssearch modification" and your site was listed third. I'm using dgssearch as the basis of a site I'm building and noticed that it doesn't support boolean searches (e.g. nissan and maxima). You guys appear to have modified the base code to support this kind of search.

I might be out of line in asking, but what the hell. Would you mind sharing the modified search code? I'm fairly new to php coding and this would save me a bunch of time.

Thanks for the consideration.

Mark Russell
www.findingautos.com
Grant MalcolmTue, 10 Feb 2004, 12:57 pm

Re: DGSFound

Hi Mark

Mark Russell wrote:
> I might be out of line in asking, but what the hell. Would
> you mind sharing the modified search code? I'm fairly new to
> php coding and this would save me a bunch of time.

It's actually not boolean, but it does allow searching on keywords rather than just phrases. The key being to split the search string into individual tokens and then build the query. It's very inefficient!

This was something I hacked together from a search routine in Phorum. Licensing details here: http://phorum.org/license.txt

The following works fine for PostgreSQL but I don't see any reason why it shouldn't also work for any SQL db. It needs to be dropped into db.php in the libs/search/ directory. There should be enough context for you to pick up where it belongs.

$statement .= ' WHERE ';
if (strlen($tableAssoc) > 0)
$statement .= $tableAssoc . ' AND ';
$statement .=' (';

$search = $q;
$search=stripslashes($search);
$search=eregi_replace("[[:space:]]+", " ", $search);
$search=trim($search);
$searchtext = htmlentities($search);
$q=$searchtext;
if($search!=""){
$params = split(" ", $search);
$InQuotedString = 0;
$tokNum = 0;
$tokens = array();
$tokens[$tokNum] = "";
for($i=0; $i if(!IsSet($tokens[$tokNum])){
$tokens[$tokNum] = "";
}
$param = $params[$i];
if(ereg("^\"", $param) || ereg("^[+-]\"", $param)){
$InQuotedString = 1;
}
if($InQuotedString == 1){
$tokens[$tokNum] .= ereg_replace("\"", "", $param) . " ";
}
else{
$tokens[$tokNum++] = $param;
}

if(ereg("\"$", $param)){
$InQuotedString = 0;
$tokens[$tokNum] = chop($tokens[$tokNum]);
echo "\n\n";
$tokNum++;
}
}
}

$statement .= "(";
for($j=0; $j $x=0;
reset($sfields);
while (list(, $entry) = each($sfields)) {
$x++;
$token = ereg_replace(" $", "", $tokens[$j]);
if(ereg("^\\+", $token)){
$token = ereg_replace("^\\+", "", $token);
$statement .= "$entry ~* '$token'";
} elseif(ereg("^\\-", $token)) {
$token = ereg_replace("^\\-", "", $token);
$statement .= "$entry NOT ~* '$token'";
}else{
$statement .= "$entry ~* '$token'";
}
if ($x < count($sfields))
$statement .= ' OR ';
}
if($j $statement .= ") AND (";
}
$statement .= ")";

[%sig%]
Walter PlingeWed, 11 Feb 2004, 06:12 am

Re: DGSFound

Thanks Grant. After posting this message and seeing what kind of "Tech" forum it is, I find it quite amusing that the best help I've ever received from a Tech forum was for Tech associated with theatre productions.

Cheers,

Mark
Massachusetts, USA
Walter PlingeThu, 12 Feb 2004, 11:38 am

Re: DGSFound

Grant,

I'm sorry to have to bother you again, but I've tried inserting the code you posted into db.php countless different ways and I can't get it to work. Can you either post the entire file contents or send it to me in an attachment to mark@findingautos.com?

Thanks for your effort.

Mark
Walter PlingeThu, 12 May 2005, 11:25 pm

Re: DGSFound

Hi Grant,

I think it's great that you've offered help with the DGS Search application... Would you be willing to share the file 'db.php' with me as well, as I seem to be having the same issue implementing it as Mark had. If you are willing to help out, that would be great!

Thanks,
David
Walter PlingeFri, 9 Sept 2005, 05:34 am

Re: DGSFound

There is a modified version of db.php available on trabiteam.de. I haven't tried it since I use the filesearch but I thought I would share the link with you.

http://trabiteam.de/dlc/show_dl2.php?id=71&lang=en

-=DKC=-
← Back to Tech Talk