There's a definite advantage - speed.
If you use this version:
%hash = $sth->fetchrow_hash(),
Perl will have to fetch the whole row and stuff it into the hash. If the row happens to have 100 cols and 50 of them have 1meg of data, it will (usually) be much slower than grabbing a ref and getting only what is needed when it is needed.
Your bonus question is directly related. To implement fetchall_array(), it'd have to slurp the entire table just to stuff it into your @array.
Not terribly efficient. If you really want to do that, they make you write it yourself. One fairly easy way would be to copy the deref'd array ref into a new array:
@data = @{$sth->fetchall_arrayref()};
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.