in reply to Database hash/array mapping and OO
An approach would be to not bless the returned array reference, but bless a hash reference which holds both the array reference with the records, and the column names:
Now, in User::get_user(), you get:... my $self = {}; $self->{records} = $sth->fetchall_arrayref(); $self->{columns} = \%columns; ...
Note, the code is untested, so there could be a syntax error lurking in there somewhere, but I hope I got the point across.... return $self->{records}->[$row][{$self}->{columns}->{$field}]; ...
Arjen
|
|---|