Perrin:
On Thu, 2003-04-03 at 12:15, Perrin Harkins wrote:
> Rafael Caceres wrote:
> > I'm trying to separate DBI stuff from the template -following the
> > comments on separating DBI from the template, but I'm having a problem
> > finding the correct way to pass variables used in the bind_columns() DBI
> > function.
>
> You need to grab all the data and copy it into your own data structure
> which you pass to the template.
Pre-fetching all the data and then passing a reference to an array of
arrays (or array of hashes) would indeed work. My understanding is that
the memory price to be paid for very large datasets could be huge: once
for the data array itself and once for the full template content before
it's printed by the Template. I'm looking for a way to avoid that.
To try to avoid that, I've attempted:
my (@datarefs);
...
@datarefs=(\$fld1,\$fld2);
$dbi_statement_handle->bind_columns(@datarefs);
$$vars{"datarefs"[EMAIL PROTECTED];
Then, in the template:
[% datarefs.0 %]
should dereference the first element of the @datarefs array and print
the value, but it does not.
Curiously enough, the following, placed right after the template
displays its output, does work back in perl:
print "the datafield was ${$datarefs[0]}\n"
Is there a way to force TT to correctly interpret the data type
(references) of the @dataref array elements?
Regards,
Rafael
_______________________________________________
templates mailing list
[EMAIL PROTECTED]
http://lists.template-toolkit.org/mailman/listinfo/templates