Akopia Akopia Services

[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date ][Minivend by thread ]

[mv] Finally have working SQL invocation



******    message to minivend-users from "Christopher P. Lindsey" <lindsey@mallorn.com>     ******

I never did figure out why [loop search] is different with only one
returned record, but I did find a workaround with [sql array].  I'm
posting it here for the benefit of the list and archives.

The most surprising thing to me was discovering that an [sql array] query
also needs its own interpolate tags to access scratch variables, etc.

[perl interpolate=1 arg=scratch]
my $results=
[sql type=array interpolate=1]select p.code, p.description, p.invasive, p.sci_name, h.hardiness_name, p.image_name, s.size_name, p.price from plant as p left join size as s on s.size_id = p.size_id left join category as c on c.category_id = p.category_id left join hardiness as h on h.hardiness_id = p.hardiness_id where c.category_name ='[scratch category]' and p.sci_name > '[scratch letter]%' order by p.sci_name limit [scratch
 start],[scratch chunk]
[/sql]
;
foreach $i (@$results) {
   my ($code, $desc, $invasive, $sci_name, $hardiness, $image, $size, $price) =
      (@$i[0], @$i[1], @$i[2], @$i[3], @$i[4], @$i[5], @$i[6], @$i[7]);

   # do my thing here, i.e.

   $a .= "$sci_name is a nice plant, hardy to $hardiness.<br>\n";
}
return $a;
[/perl]

Chris
-
To unsubscribe from the list, DO NOT REPLY to this message.  Instead, send
email with 'UNSUBSCRIBE minivend-users' in the body to Majordomo@minivend.com.
Archive of past messages: http://www.minivend.com/minivend/minivend-list


Search for: Match: Format: Sort by: