Kelly Thompson wrote:
> I suggest you move the DBI interaction into the perl, script.
> Just a thought...

For most applications, yes, a clear separation of concerns is a
Good Thing[tm].  But then the DBI plugin exists specifically for
those occasions when you can't, don't want to, or don't need to
strive for a clearly separated, highly tiered solution.

A nice half-way house is to subclass the DBI plugin and have it
hide query specifics behind custom methods.

   package Template::Plugin::MyDB;
   use base 'Template::Plugin::DBI';

   sub fetch_user_by_id {
       shift->execute('SELECT * FROM user WHERE id=?', @_);
   }

In a template:

   [% USE MyDB(...) %]
   [% user = MyDB.fetch_user_by_id(123) %]

A

_______________________________________________
templates mailing list
templates@template-toolkit.org
http://mail.template-toolkit.org/mailman/listinfo/templates

Reply via email to