The next release has:

=item C<FetchHashKeyName> (string, inherited) I<NEW>

This attribute is used to specify which attribute name the
fetchrow_hashref() method should use to get the field names for the
hash keys. For historical reasons it defaults to 'C<NAME>' but it
is recommended to set it to 'C<NAME_lc>' or 'C<NAME_uc>' according
to your preference.

Tim.

On Mon, Jul 16, 2001 at 10:09:19AM -0700, Alex Algard wrote:
> In that case, if you do "$sth->fetchall_arrayref ({})" is there a way to
> control the case of the keys in the returned hash? If there were a
> fetchall_hashref() function, then I would presumably just use
> "$sth->fetchall_hashref('NAME_lc')", but I'm not sure what I would do with
> "$sth->fetchall_arrayref({})" to control the case of the keys (I guess that
> I could write some type of map function, but that would be processor
> intensive for large queries). Obviously, in order to maintain portability of
> the code, I wouldn't want to rely on the database's default convention of
> using upper or lower case column names.
> 
> Thanks,
> Alex Algard
> 
> 
> > -----Original Message-----
> > From: Tim Bunce [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, July 16, 2001 9:13 AM
> > To: Ronald J Kimball
> > Cc: Tim Bunce; Alex Algard; dbi-users
> > Subject: Re: fetchall_hashref() - does/will it exist?
> >
> >
> > On Mon, Jul 16, 2001 at 09:46:38AM -0400, Ronald J Kimball wrote:
> > > On Sun, Jul 15, 2001 at 09:15:02PM +0100, Tim Bunce wrote:
> > > > On Sat, Jul 14, 2001 at 05:00:11PM -0700, Alex Algard wrote:
> > > > > > It was a mistake. I've deleted it now. Use...
> > > > > >     $ary_ref = $sth->fetchall_arrayref( {} );
> > > > >
> > > > > That's actually what I'm doing now. My concern is that using
> > > > > fetchall_arrayref() by passing an anonymous hash as an argument is
> > > > > susceptible to typos when the columns are being
> > initialized, and the code
> > > > > also requires more maintenance, for example, if a table
> > column is added or
> > > > > renamed. In addition, using this approach on a table with
> > many columns would
> > > > > result in a lot of code. So please consider adding
> > fetchall_hashref() to
> > > > > DBI.
> > > >
> > > > Pass a ref to an empty hash. See the docs, and the code.
> > > >
> > >
> > > I'm curious why this interface was chosen-- a function named
> > > 'fetchall_arrayref' will actually return a hash ref instead if the first
> > > argument happens to be a hash ref -- instead of just having a function
> > > called 'fetchall_hashref'.  This behavior seems counter-intuitive and
> > > likely to cause confusion.
> >
> > fetchall_arrayref always returns an array ref. One entry for each row.
> >
> > The parameter determines what's *in* the array for each row.
> >
> > Tim.
> 

Reply via email to