[Catalyst] Variable in where clause

Dan Boger perl at peeron.com
Wed Sep 14 06:03:34 CEST 2005


On Tue, Sep 13, 2005 at 11:51:21PM -0400, Danh Nguyen wrote:
>    [% USE DBI('dbi:SQLite:C:\minimojo.db ') %]
>    
>     [% SET myid= 2 %]
>       
>        [% FOREACH user = DBI.query('SELECT * FROM user WHERE id= myid') %]
>    
>        <table border="1" width="54%">
>          <tr>
>            <td width="15%">User ID</td>
>            <td width="85%">[% user.id %]<td>
>          </tr>
>          <    </table>
>        [% END %]
>    
>    I have tried all possible syntax, but cannot get it. Anyone could help me
>    out?

I haven't used TT:DBI yet, but wouldn't something like this work?

  [% FOREACH user = DBI.query('SELECT * FROM user WHERE id= ?', myid) %]


-- 
Dan Boger



More information about the Catalyst mailing list