[ic] search-region/query conflict? - Please Help
Mike Heins
mike at perusion.com
Wed Jun 23 17:21:17 EDT 2004
Quoting Thomas J.M. Burton (tom at globalfocusdm.com):
> Hi IC users,
>
> I'm reposting this question in a simplified form as it may make
> providing help easier. I've worked with the code a bit more since my
> original post but am still experiencing the same problem.
>
> In a catalog I'm developing, I have a promotions table which will
> contain data for various promotions. In a file that I'm including in the
> page template, I am running a query on the promotions table to check for
> current promotions and then processing each result according to
> specifics based on promotion type.
>
> This catalog is running in Interchange 5.0 and using the default DB.
>
> The problem I'm encountering is that the query for the promotions table
> is only returning two results when it's used in the results.html page.
> Any other page in the catalog has the proper full set of results
> returned from the query.
>
> As I mentioned, I've simplified the query code by doing all through perl
> (before I had a [query] tag with arrayref specified and processed the
> results in a chunk of perl code). Below is the code for the query and a
> simple output of results.
>
>
> [perl tables="promotions"]
> # Query promotions table
> my $sql = qq{SELECT code,discount_amount
> FROM promotions ORDER BY type,active_month};
>
> my $table = 'promotions';
>
> my ($results, $col_name_hashref, $col_name_arrayref)
> = $Tag->query({ sql => "$sql", table => "$table"});
>
> my $hash_results = $Tag->query( { sql => $sql,
> hashref => 'my_results' } );
>
> # Loop through query results, output text
> foreach my $row (@$hash_results) {
> $out.= "$row->{code} ";
> $out.= "$row->{discount_amount}\n";
> }
>
> return $out;
> [/perl]
>
>
> Why would this return only a limited number of results (in this case,
> only 2) when included in the results.html page? I suspect it has
> something to do with there being a [search-region] in the results page,
> but I don't know what to do to prevent the conflict.
I don't understand why you are only getting two things, but I think
you have a more basic thing that should be done.
This is normal for IC:
[perl tables="promotions"]
# Query promotions table
my $sql = qq{SELECT code,discount_amount
FROM promotions ORDER BY type,active_month};
my $db = $Db{promotions};
my $hash_results = $db->query({ sql => $sql, hashref => 1 });
# Loop through query results, output text
foreach my $row (@$hash_results) {
$out.= "$row->{code} ";
$out.= "$row->{discount_amount}\n";
}
return $out;
[/perl]
--
Mike Heins
Perusion -- Expert Interchange Consulting http://www.perusion.com/
phone +1.765.647.1295 tollfree 800-949-1889 <mike at perusion.com>
People who want to share their religious views with you
almost never want you to share yours with them. -- Dave Barry
More information about the interchange-users
mailing list