* Viljo Marrandi ([EMAIL PROTECTED]) [010730 10:29]:
> > [% FOREACH result = DBI.query('SELECT DATE_FORMAT(now(), \'%M %d\') as now')
> > %]
> > Time is [% result.now %]
> > [% END %]
> 
> 
> Got it working, thanks. But now i have another question. Let's say i 
> want to make this query:
> 
> SELECT * FROM table WHERE type = ? AND headline LIKE '%?%'
> 
> Then hows this correctly accomplished? I can use two '?'s just fine but 
> Plugin::DBI doesn't seem to find this last '?' between '%'s. Now what?

At least in normal Perl DBI you'd do:

 my $sql = "SELECT * FROM table WHERE type = ? AND headline LIKE ?";
 my $sth = $dbh->prepare( $sql );
 $sth->execute( 'type', '%headline%' );

Which looks like it translates to:

[% sql = 'SELECT * FROM table WHERE type = ? AND headline LIKE ?' %]
[% query = DBI.prepare( sql ) %]
[% FOREACH blah = query.execute( 'type', '%headline%' ) %]
...
[% END %]

Generally, you need to put the wildcards into the bound value rather
than around the placeholder.

Hope this helps,

Chris

-- 
Chris Winters ([EMAIL PROTECTED])
Building enterprise-capable snack solutions since 1988.


Reply via email to