in reply to Re: Template::Toolkit, DBI and mysql % wildcards
in thread Template::Toolkit, DBI and mysql % wildcards
code:[% USE DBI('dbi:mysql:logs','','') %] [% SET dbh = dbi.prepare(query) %] [% FOREACH user = user_list %] [% FOREACH item = dbh.execute(user) %] [% item.user %] [% END %] [% END %]
That's quite handy. Also when you put all the database stuff inside the templates, you can easily switch between databases, without touching the perl code.$template->process(\$tt, {query => $query, user_list => [foo, bar]) or + die $template->error(); [download]
|
|---|