Hi,
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.
My perl code has:
my ($vars,$fld1,$fld2);
$dbi_statement_handle=$dbh->prepare(select fld1,fld2 from table) ||
die($@);
$dbi_statement_handle->execute or die ($@);
$dbi_statement_handle->bind_columns(\$fld1,\$fld2);
# OR the equivalent:
# $sth->bind_columns(\($fld1,$fld2));
#Now I attempt to have the binded columns available to the template.
#I've tried 3 different ways, but none work:
#method1:
$$vars{"fields"}=[\$f_id,\$f_fapert,\$f_tipo,\$f_area,\$f_descrip];
#method2:
$$vars{"fields"}={"fld1"=>\$fld1,"fld2"=>\$fld2};
#method3: which gives an Template::Stash::XS get(argN) must be a scalar
or a listref at line NN
$$vars{"fld1"}=\$fld1;
$$vars{"fld2"}=\$fld2;
And in the template, for the different methods I tried:
[% WHILE sth.fetchrow_arrayref #very 'clean' for the template
maintainer%] ...
[% #method 1 %]
[% $fields.0 %]
[% #method 2 %]
[% #fields.fld1 %]
[% method 3 %]
[% fld1 %]
...
[% END %]
Please give me a clue as to the 'right' way to pass the template the
variables used in the bind_column() call.
Rafael
_______________________________________________
templates mailing list
[EMAIL PROTECTED]
http://lists.template-toolkit.org/mailman/listinfo/templates