in reply to RE: RE: References of Eternal Peril (while we're on the subject)
in thread References of Eternal Peril
Indeed there is:
... can be written ...my @ar = (); while (my $hr = $sth->fetchrow_hashref() ) { push @ar, $hr; } $s->ar = \@ar; $s->rows = @ar;
$s->ar = $sth->fetchall_arrayref({}); $s->rows = @{$s->ar};
On a side note, fetchall_arrayref() is one of my favorite methods because HTML::Template templates take an arrayref of hashrefs as a parameter for loops. You can output a table really easily like so:
The template file looks like this:# Assume $sth is a valid statement handle my $params = $sth->fetchall_arrayref({}); my $template = new HTML::Template (filename => 'file.name'); $template->param(TABLENAME => $params); print $template->output();
The stuff between the <TMPL_LOOP> tags outputs for each row returned by the query, and it only takes two lines of perl to get the rows from the db to the template.<TABLE> <TMPL_LOOP NAME=TABLENAME> <TR><TD><TMPL_VAR NAME=COLUMN1></TD><TD><TMPL_VAR NAME=COLUMN2></TD> +</TR> </TMPL_LOOP> </TABLE>
-Matt
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: RE: RE: RE: References of Eternal Peril (while we're on the subject)
by rdw (Curate) on Aug 11, 2000 at 21:59 UTC |