@row_ary = $sth->fetchrow_array; $ary_ref = $sth->fetchrow_arrayref; $hash_ref = $sth->fetchrow_hashref;
For the purposes of this discussion, it is a pragmatic simplification to say that you can either get an array ref or hash ref back for each row of a table.
When database fields are removed or switched in position, I call these destructive or positional field mutations. It is clear that Perl code based on array ref fetches will break in the face of such table mutations. On the other hand, hash ref fetches will not fail in this case.
When database field names are changed, I call this a labeling mutation. In this case, array ref fetches are robust to the mutation while hash ref fetches will break.
So, the dilemma which pops up when deciding on how to structure one's objects (as hashrefs or array refs) again rears its ugly head when fetching data.
And so the topic of discussion is: How does one write Perl code such that it can work without modification in the face of labeling, destructive, or positional field mutations?
In reply to Topics in Perl Programming: Table-Mutation Tolerant Database Fetches with DBI by princepawn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |