http://qs321.pair.com?node_id=318561


in reply to HTML::Template, DBI and <TMPL_LOOP>'s

I believe the technique I was using was removed from DBI about 3 months after my post. It was replaced with a more elegant (IMHO) system that can replicate the same results with newer versions of DBI.

In the earlier example I was trying get DBI to return an array reference of hash references with a single DBI method call. I don't see the need to break something up into multiple steps (prepare/execute/fetchall_arrayref) if DBI provides an all-in-one "utility method" that does these things underneath. Plus, as jeffa mentioned, it cuts down the number of places where you need to specify the names of the columns -- which is convenient if you ever need to make changes.

Here's how I would do it using a more recent version of DBI:

my $statement = q{ SELECT id , title FROM movie }; # $template is an HTML::Template object $template->param( movies => $dbh->selectall_arrayref($statement, { Slice => {} }), );
Dan Kubb, Perl Programmer