[ic] looping vs. query

Jon Jensen jon@akopia.com
Sat, 28 Apr 2001 14:18:27 -0500 (CDT)


On Sat, 28 Apr 2001, Dean Hall wrote:

> I'm trying to get every row in the DB with category_id of 2. Here's what I
> do:
> 
> [loop prefix='prod' interpolate=1 search='fi=products/se=[scratch
> category_id]/sf=category_id']
> ...
> [/loop]
> 
> [scratch category_id] resolves to 2 in this case; the problem is that I'm
> getting a bunch of garbage when I reference [prod-code], [prod-field name],
> or any other [prod-field xxx].

I just tried your exact query (or as close as I can do without your data)
on the default foundation demo products data and it worked fine:

[set price]19.99[/set]

[loop prefix='prod' search='fi=products/se=[scratch price]/sf=price']
<p>
Product SKU: [prod-code]<br>
Name: [prod-field description]<br>
Price: [prod-field price]
</p>
[/loop]

Maybe there's some extremely subtle difference between your query and
mine, but I don't see anything. The "interpolate=1" isn't needed, but the
query still works with it.

I tested this under stock IC 4.6.5 and the latest 4.7.x in CVS, with DBM.
Double-check your table definition. Try doing the query all alone on a
test HTML page.

> I can't reset a scratch variable after it's been set (even with
> [calc]$Scratch->counter++;return;[/calc])

Try $Scratch->{counter}++ instead. $Scratch is a hashref. This is in the
docs.

> Due to the awful, awful documentation for Interchange, I need some
> help.

I'm starting to get a little tired of the endless criticism of the
documentation. I understand the frustration when something doesn't work as
expected right away -- I experience that frequently. But many people have
put a lot of work into Interchange, including the documentation, and it
gets old hearing complaints. Once you figure out your specific problem
maybe you can write it up in a FAQ for others.

Jon