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
{
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:
{},
{
'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?
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?
$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 & Web Development.
rgbworld.com
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 & Web Development.
rgbworld.com