- Selecting multiple rows
my $data = {}; my $sth = $dbh->prepare( 'SELECT name, colour, shape FROM thing WHERE smell=?' ); $sth->execute('bad'); while ( my $row = $sth->fetchrow_hashref ) { $data->{$row->{colour}}{$row->{shape}} = $row; }
- should have been ...
my $data = $dbh->selectall_hashref( 'SELECT name, colour, shape FROM thing WHERE smell=?', [qw(colour shape)], undef, 'bad' );