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

Hi drfrog,

The point is that their is no need to build the list of hashes! You can get it straight from the database. By changing:

# This method returns a reference to an array of array-refs my $site = $sth->fetchall_arrayref;
to:
# This method returns a reference to an array of hash-refs my $site = $sth->fetchall_arrayref( {} );
Produces a structure which can be directly passed to the TMPL_LOOP, like this:
$template->param( view => $site );
assuming of course that the one field returned, using your example code, was name.

My reference to dkubb was not to in any way impune what he did, but merely to try and cite the appropriate references as I knew them. The method he used originally was removed and this one obviously added in its place!

jdtoronto

Replies are listed 'Best First'.
Re: Re: Re: HTML::Template, DBI and <TMPL_LOOP>'s
by drfrog (Deacon) on Jan 03, 2004 at 23:07 UTC
    doh!
    next time i should try and read the whole thread, and then reply! answering 10 minutes before leaving work didnt help either!

    thanks for asking this question, i had a bit of disconnect on this loading hashes straight from the database too!

    btw:
    i didnt take your references to dkubb as anything negative :)