in reply to The fetchall_answer!
in thread By ref or by ..well..ref!
This is the thing I most dislike about DBI's API. There are a ton of efficient ways to use positional logic, but if you want to use name-based logic, you are definitely a second-class citizen. However name-based logic is much better from a development perspective if performance is not utterly critical.
But anyways you can just use a bit of code like this:
The fact that someone doesn't provide the interface that you want is no reason not to provide it yourself...# Takes a statement handle, and returns the entire result # set as a reference to an array of hashes. sub fetchall_arrayref_hash { my $sth = shift; my @rows; while (defined(my $row = $sth->fetchrow_hashref())) { push @rows, $row; } return \@rows; } # Then elsewhere $template->param(table1 => fetchall_arrayref_hash($sth));
|
|---|