in reply to SQL Questions
The catch is that selectall_hashref needs a key field to use as the hash key, so these have to be unique. If you don't have a unique column, you can use the alternative array fetch method and make do, or something like this:my $hash = $dbh->selectall_arrayref("SELECT id,name,age FROM foo", "id");
# ... my @rows; $sth->execute(); while (my $row = $sth->selectrow_hashref()) { push(@rows, { %$row }); # Force unique reference }
|
|---|