From the
DBI docs.
$hash_ref = $dbh->fetchall_hashref($key_field);
The $key_field parameter provides the name of the field that holds the value to be used for the key for the returned hash.
The $key_field parameter can also be specified as an integer column number (counting from 1). If $key_field doesn't match any column in the statement, as a name first then as a number, then an error is returned.