[ic] sql queries inside perl tag

Kyle Cook interchange-users@lists.akopia.com
Wed Aug 1 23:27:00 2001


At 06:50 PM 8/1/01, you wrote:
>Forgive me for sounding ignorant, plus I'm coming up on 13 hour work day 
>here so there are mis-firing synapses in my head, but where would I place 
>perl -W?
>
>I tried switching the line in /usr/local/interchange/bin/interchange
>to read #!/usr/local/bin/perl -W


I believe he meant as a stand-alone script, would it pass perl checks.

Looks like some syntax errors (missing quotes...).

To be a little less abusive to your database (especially if this code
is in a search results page) would be to use this structure:

(although really, the db really needs some re-organization :-)


Not tested, but the basic idea is there...

[query list=1 prefix=outer sql="SELECT sun
         FROM products
         WHERE code = '[item-code]'"]

         [calc]
         @sunarray = split(/,/, '[outer-param sun]'); # breaks with (') in 
the field!
         $out = '';
         foreach $option (@sunarray) {
                 $out .= ($out) ? ",'$option'" : "'$option'";
         }
         return '';
         [/calc]


         [query list=1 prefix=inner sql="SELECT val
                 FROM sun WHERE code in ([calc]$out[/calc])'
                 ORDER BY val"]

                 [inner-param val]<br>

         [/query]

[/query]

Good luck,

Kyle