hugh baker <[EMAIL PROTECTED]> writes:

>     hi-
>
> i think i found a bug in the DBI Plugin:
>
> my template looks like this:
>
> [% META title = "People" %]
> [% USE DBI(db.dsn,db.name,db.pass) %]
> [% sort = DBI.quote('fname') %]
> [% statement = DBI.prepare('SELECT people.idn, people.fname, people.lname, bios.text 
>FROM people LEFT JOIN bios USING (idn) ORDER BY ?') %]
> [% "<h2>"; sort; "</h2>" %]
> [% FOREACH person = statement.execute(sort) %]
>    [%# WRAPPER section %]
>         <a name="[% person.idn %]" />
>           <h2>[% person.fname %] [% person.lname %]</h2></a>
>       [% person.text | html_para %]
>    [%# END %]
> [% END %]
>
> the statement is executed and produces output, but the rows are not
> ordered as expected.  when i replace the '?' in the SQL statement with
> a literal value, it returns the expected order.  it works in perl as
> expected so the bug is TT.  looking through the code, the execute
> method is passed to directly to the DBI object.
>

i don't want to start talking to myself, but i think i am narrowing in on the problem 
:-)
i now have:

[% sort = params.sort %]
[% statement = DBI.prepare('SELECT * FROM people  LEFT JOIN bios USING (idn) ORDER BY 
?') %]
[% FOREACH person = statement.execute("${sort}") %]
                                       ^
                                       leaving out these quotes breaks the template.

so it looks like the problem is somwhere admist all the reference magic performed by 
TT.
i would leave it here, but since i'm grabbing the binding variable
from the query string i would like to do:

[% sort = DBI.quote(params.sort) %]

but this breaks the template again.
                                       
i'll go research dereferencing.

    thanks,

    hugh.


    


Reply via email to