

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
12 messages in org.perl.dbi-usersRE: fetchall_hashref() - does/will it...| From | Sent On | Attachments |
|---|---|---|
| Alex Algard | Jul 13, 2001 4:16 pm | |
| Alex Algard | Jul 13, 2001 4:20 pm | |
| Tim Bunce | Jul 14, 2001 12:31 pm | |
| Alex Algard | Jul 14, 2001 4:59 pm | |
| Bart Lateur | Jul 15, 2001 3:32 am | |
| Tim Bunce | Jul 15, 2001 1:14 pm | |
| Neil Lunn | Jul 15, 2001 9:12 pm | |
| Ronald J Kimball | Jul 16, 2001 6:46 am | |
| Tim Bunce | Jul 16, 2001 9:12 am | |
| Ronald J Kimball | Jul 16, 2001 9:20 am | |
| Alex Algard | Jul 16, 2001 10:08 am | |
| Tim Bunce | Jul 16, 2001 2:12 pm |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | RE: fetchall_hashref() - does/will it exist? | Actions |
|---|---|---|
| From: | Alex Algard (alg...@stanfordalumni.org) | |
| Date: | Jul 16, 2001 10:08:57 am | |
| List: | org.perl.dbi-users | |
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:Tim....@pobox.com] 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.







