my $sth = $dbh->prepare('select * from songs limit 5');
$sth->execute;
tie my @data, Tie::STHRows, $sth;
my $tmpl = q|
|;
my $template = HTML::Template->new(scalarref => \$tmpl);
$template->param(data => \@data);
print $template->output;
####
print Dumper \@data;
__END__
$VAR1 = [
{
'artist' => 'Van Halen',
'genre' => 'Rock & Roll',
'album' => 'Van Halen II',
'title' => 'Spanish Fly',
'year' => '1979',
'id' => '1'
},
$VAR1->[0],
$VAR1->[0],
$VAR1->[0],
$VAR1->[0]
];
####
print Dumper $_ for @data;
__END__
$VAR1 = {
'artist' => 'Van Halen',
'genre' => 'Rock & Roll',
'album' => 'Van Halen II',
'title' => 'Spanish Fly',
'year' => '1979',
'id' => '1'
};
$VAR1 = {
'artist' => 'Van Halen',
'genre' => 'Rock & Roll',
'album' => 'Van Halen II',
'title' => 'Beautiful Girls',
'year' => '1979',
'id' => '2'
};
$VAR1 = {
'artist' => 'Van Halen',
'genre' => 'Rock & Roll',
'album' => 'Van Halen II',
'title' => 'Dance The Night Away',
'year' => '1979',
'id' => '3'
};
$VAR1 = {
'artist' => 'Van Halen',
'genre' => 'Rock & Roll',
'album' => 'Van Halen',
'title' => 'Eruption',
'year' => '1978',
'id' => '4'
};
$VAR1 = {
'artist' => 'Van Halen',
'genre' => 'Rock & Roll',
'album' => 'Van Halen',
'title' => 'You Really Got Me',
'year' => '1978',
'id' => '5'
};
####
sub FETCH {
my $self = shift;
$self->[0]->fetch;
my %row = %{$self->[1]};
return {%row};
}