If you don't want to define a key field, then you can't get the functionality you want. Come on, be reasonable. :)
Note that $key_field can be an arrayref, a column number, or an arrayref containing a list of column numbers:
#!/usr/bin/perl -w
use strict;
use DBI;
use Data::Dumper;
$|++;
my $dbh = DBI->connect("dbi:mysql:wordpress","username","password");
my $sth = $dbh->prepare('SELECT ID, placeName FROM wp_ajax_places WHER
+E ID <= 5');
$sth->execute;
my $h = $sth->fetchall_hashref([ 1..2 ]);
print Dumper(\$h);
Output:
$VAR1 = \{
'4' => {
'Akiachak AK' => {
'ID' => '4',
'placeName' => 'Akiachak AK'
}
},
'1' => {
'Ester AK' => {
'ID' => '1',
'placeName' => 'Ester AK'
}
},
'3' => {
'Akhiok AK' => {
'ID' => '3',
'placeName' => 'Akhiok AK'
}
},
'2' => {
'Aguikchuk AK' => {
'ID' => '2',
'placeName' => 'Aguikchuk AK'
}
},
'5' => {
'Akiak AK' => {
'ID' => '5',
'placeName' => 'Akiak AK'
}
}
};
--
Education is not the filling of a pail, but the lighting of a fire.
-- W. B. Yeats
|