Hello,
This might be another rather stupid question but anyway... I have 2
files: src/index.ttml, lib/menu.html and config/conf. In conf(it's
PRE_PROCESS'ed) i connect to MySQL dbase. In index.ttml i can do
DBI.query with no problem, but if i do it from menu.html, which is
included to index.ttml query fails and in error_log i see this:
DBI::db=HASH(0x8b8e210)->disconnect invalidates 1 active statement
handle (either destroy statement handles or call finish on them before
disconnecting) at
/usr/local/lib/perl5/site_perl/5.005/Template/Plugin/DBI.pm line 280.
Template::Plugin::DBI::DESTROY('Template::Plugin::DBI=HASH(0x8b4809c)')
called at /usr/local/lib/perl5/site_perl/5.005/Template/Service.pm line 110
eval {...} called at
/usr/local/lib/perl5/site_perl/5.005/Template/Service.pm line 110
Template::Service::process('Template::Service=HASH(0x8b000cc)',
'index.ttml', 'HASH(0x8b4536c)') called at
/usr/local/lib/perl5/site_perl/5.005/Template.pm line 59
Template::process('Template=HASH(0x8b4fb0c)', 'index.ttml',
'HASH(0x8b4536c)', 'Apache=SCALAR(0x89967a8)') called at
/usr/local/lib/perl5/site_perl/5.005/Inspiral/Koolibri.pm line 38
MyHandler::handler('Apache=SCALAR(0x89967a8)') called at /dev/null line 0
eval {...} called at /dev/null line 0
From Template::Plugin::DBI manual i read that dbi disconnect i made
when it gets out of scope, maybe this is the problem?
P.S. dbi stuff in menu.html looks like this:
[% item = DBI.query('SELECT * FROM table LIMIT 1') %]
[% item.body %]
Hmm, and now i remember one other problem too. Everywhere in DBI
examples used only FOREACH to show query results. But let's say i get 3
answers for query and i want to show only second? How is this done?
Something like: [% result.header[1] %], where [1] is second element...
Well, in EmbPerl it's something like [+ $$result[1][0] +], but in TT no
idea.
Thanks in advance,
Viljo