I'm fairly new to TT, but its significantly simplified a large project
I'm working on. I am, however, having issues with the DBI plugin,
specifically using an already existing connection from the calling
script for some simple queries.
The documentation for some of these plugins are fairly sparse, they
show plenty about the TT directives, but not much of the perl code
used to implement it, so this may well be something simple. I'm
wanting to use an existing DBI handle for a simple predefined query:
[% USE DBI( dbh = global_dbh ) %]
<select name="genre">
[% FOREACH result = DBI.query($genre_query) %]
<option value="[% result.ID %]">[% result.Desc %]</option>
[% END %]
And then, on the perl side, I specify the dbh, and the query:
my $dbh = DBI->connect("dsn-stuff");
$tt->process("page.html",
{
global_dbh => \$dbh,
genre_query => "SELECT ID, Desc FROM Table;"
}
);
Alas, when I request the page, I get nothing, and the httpd error log has this:
[Tue Jun 27 17:06:44 2006] [error] [client 71.2.112.154] undef error -
Can't call method "execute" on an undefined value at
/usr/lib/perl5/vendor_perl/5.8.8/i386-linux/Template/Plugin/DBI.pm
line 268., referer: http://pe6300.psx.net/catalog/
This doesn't make sense to me, because the query() method should do a
prepare and an execute, right?
_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates