Another Perl/MySQL question for you:
How can I extract records from a database without knowing the positions of the fields, only the field names.
Currently I use:
$sth = $dbh->prepare ("SELECT * FROM country ORDER BY name ASC");
$sth->execute (); while ( ($id, $name) = $sth->fetchrow_array()) {
push @countries, { id => "$id", name => "$name" };
} $sth->finish ();
$dbh->disconnect ();
But, as you can see, it requires me to know the order the fields are in.
I did try getting to data into hashes using fetchrow_hashref a while back, but couldn't get it to work.
Thanks in advance,
Allen
In case anyone's wondering, here's how o do a fetchrow_hashref:
while ( $country = $sth->fetchrow_hashref()) {
push @countries, { id => "$country->{id}", name => "$country->{name}" };
} Allen