On Thu, Jun 07, 2001 at 05:27:16PM -0400, Chas Owens wrote:
> In DBI, it (fetchrow_hashref, not fetchhash) returns a hash where the
> keys = column names and values = value of the columns on the row. I
> consider it a generaly bad thing since it forces you to alias your
> columns when you have two (or more) columns with the same name or an
> expersion as a column in you result set.
The flipside to this is code maintainability. Consider:
while (defined($row = $sth->fetchrow_arrayref)) {
print $$row[4];
}
while (defined($row = $sth->fetchrow_hashref)) {
print $$row{'permissions'};
}
Quick, what kind of information is likely to be in the row being printed? :)
Aliasing in the query is easy, and queries (at least in most of my code) are
fairly static. I'm more often wandering through code trying to figure out
what's accessing what, and using hashes makes things much easier to
understand at a glance.
Michael
--
Administrator www.shoebox.net
Programmer, System Administrator www.gallanttech.com
--