Could I have written it better, cleaner, or safer?
Better and cleaner, yes. Your $data is an array of arrays and you convert it to an array of hashes by hand. Far better to have DBI do that for you.
return $dbHandle->fetchall_arrayref ({});
BTW, I would rename that variable. $db is your DB handle. What you have called $dbHandle is a statement handle. Anyone else coming to this code would be confused by that.
🦛
|
|---|