[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date
][Minivend by thread
]
RE: Sql in Perl!!
On Sat, 19 Jun 1999, Mike Wolf wrote:
> -----Original Message-----
> From: owner-minivend-users@minivend.com [mailto:shahed@avalanche.bc.ca] On
> Behalf Of Shahed Khalili
> Sent: Friday, June 18, 1999 7:17 PM
> To: 'minivend-users@minivend.com'
> Subject: Sql in Perl!!
>
> Hi All
>
> I'm trying to write sql tags in [perl]. can someone tell me why this doesn't
> work??
>
> $html .= join '' , "[sql type=array]select description from products where
> code ='" , $cod "'[/sql]";
>
> $html
> [/perl]
If you have embedded tags within a Perl block, you need to have the
interpolate flag set:
[perl interpolate=1]
... [sometag] ....
[/perl]
Note that as far as I can tell (i.e. your mileage may vary), the embedded
tags are interpreted _before_ any code in the perl block. Thus, the $cod
variable will not be interpreted. Again, this is as far as I can tell. I
could be wrong on the order of interpretation, but it is the only thing
that explains the results I get.
Have you tried just using the normal sql tags? I use them outside of perl
with good effect.
Another thing to try might be to set a scratch variable with the value you
want for cod:
[perl scratch]... $Safe{scratch}{cod}= $cod;return '';[/perl]
then use it:
[perl scratch ... interpolate=1]
...
html .= '[sql type=array]select * from foo where
code="[scratch cod]" and ...[/sql]';
...
[/perl]
You might need to add an interpolate flag to the [sql] block too. I have
had mixed results with multiple levels of interpolation, so this might not
work.
Best,
Kyle