Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

query within search_results hook

Quote Reply
query within search_results hook
I am still trying to figure out how to alter $IN->param('query') wrt a search_results hook (PRE).

I can alter the query before calling sub search() by doing this:
$IN->param('query', '54720');

What I REALLY need to do is alter 'query' so that it holds an array of values as opposed to just one value.
Q: Is this even possible?

In my hook, I have
Code:
while (my $zip = $sth->fetchrow_hashref)
{
if(distance($olat, $olon, $zip->{Latitude}, $zip->{Longitude}, $unit) <= $dist)
{
push (@output, $zip);
}
}

...

return {\@output};

When finished, @output via #print GT::Dumper::Dumper(\@output); contains:
Code:
$VAR = [
{},
{
'Latitude' => '41.687414',
'Longitude' => '-86.979701',
'State' => 'IN',
'ZipCode' => '46301'
},
{
'Latitude' => '41.36959',
'Longitude' => '-87.44849',
'State' => 'IN',
'ZipCode' => '46303'
},

etc...

@output could easily contain only 'ZipCode' which is what I need to find.

So, I have an array of zipcodes that I want to search for.
Q: How do I put @output into a query?


This code snippet is from sub search() which is called at the end of my hook.
I could put @output into @args in my hook, then this routine would have my array in $args?
Code:
my $link_sth = $links->query_sth($args);

I found this snippet on the www. It seems that "join" may be what I am looking for.
I am still unsure how to do it though, or if it is even possible? GT?
Code:
my $query_sth;
$query_sth = "SELECT ".join(",",grep(/\S/,@rows))." FROM tester";
if (scalar (@values) > 0) {
$query_sth .= " WHERE ".join(",",grep(/\S/,@values));
};

$query_sth .= ';';

Thanks again for any help,
Chris
RGB World, Inc. - Software &amp; Web Development.
rgbworld.com
Subject Author Views Date
Thread query within search_results hook rgbworld 1977 May 22, 2005, 11:12 AM
Thread Re: [rgbworld] query within search_results hook
rgbworld 1942 May 22, 2005, 12:22 PM
Post Re: [rgbworld] query within search_results hook
rgbworld 1913 May 22, 2005, 9:22 PM