in reply to Idiomatic way of getting from database result set to HTML::Template data structure?
sub inflate { my ($results) = @_; my %data; foreach my $results (@$results) { my ($mag, $issue, $article) = @{$results}{qw( mag_name issue_n +um article )}; push @{$data{$mag}{$issue}}, $article; } foreach my $mag (keys %data) { $data{$mag}{article_loop} = map { issue_number => $_, article_loop => $data{$mag}{$_}, } keys %{$data{$mag}}; } return \%data; }
It doesn't preserve the order the issues for each magazine came back from the database, but sorting should be a view question, not a data retrieval question.
------
We are the carpenters and bricklayers of the Information Age.
Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Idiomatic way of getting from database result set to HTML::Template data structure?
by Anonymous Monk on Mar 29, 2004 at 16:04 UTC | |
by dragonchild (Archbishop) on Mar 29, 2004 at 16:11 UTC | |
by Anonymous Monk on Mar 29, 2004 at 19:50 UTC | |
by dragonchild (Archbishop) on Mar 29, 2004 at 20:20 UTC |