in reply to How to add MySql Records To Array or Hash?
Hi,
the decision whether to use arrays of hashes depends on the size of the result set and other aspects (e.g. maintainability). Hashes and access by field names makes it IMHO more readable.
I would propose the following structure:
my %hash = ( 12345 => { id => 12345, position => 'QB', salary => 15000, points => 20, }, 54321 => { id => 54321, position => 'QB', salary => 14500, points => 19, }, );
To get this structure from a database via DBI have a look at http://search.cpan.org/dist/DBI/DBI.pm#selectall_hashref.
Regards
McA
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to add MySql Records To Array or Hash?
by jdlev (Scribe) on Sep 09, 2013 at 20:58 UTC | |
by McA (Priest) on Sep 09, 2013 at 22:00 UTC |