I know that:
$sth->fetchrow_hashref
returns a hashref of the fetched row from database,$sth->fetchrow_arrayref
returns an arrayref of the fetched row from database, and$sth->fetchrow_array
returns an array of the fetched row from database.But I want to know best practices about these. When should we use fetchrow_hashref and when should we use fetchrow_arrayref and when should we use fetchrow_array?
You could do worse than read DBI recipes by gmax.
It notes, among other things:
The problem arises when your result set, by mean of a JOIN, has one or more columns with the same name. In this case, an arrayref will report all the columns without even noticing that a problem was there, while a hashref will lose the additional columns
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With