Skip Menu |

This queue is for tickets about the DBI CPAN distribution.

Report information
The Basics
Id: 42483
Status: rejected
Priority: 0/
Queue: DBI

People
Owner: Nobody in particular
Requestors: KES [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: DBI improvement to slice results
http://search.cpan.org/~timb/DBI-1.607/DBI.pm#fetchall_arrayref How to fetch each row as array ref by slice by column name? It seems impossible. Is next improvement will be reasonable? diff: -To fetch only the fields called "foo" and "bar" of every row as a hash ref (with keys named "foo" and "BAR"): - $tbl_ary_ref = $sth->fetchall_arrayref({ foo=>1, BAR=>1 }); +To fetch only the fields called "foo" and "bar" of every row as a hash ref (with keys named "foo" and "BAR"): + $tbl_ary_ref = $sth->fetchall_arrayref({ foo, BAR }); +To fetch only the fields called "foo" and "bar" of every row as a array ref (with keys named "foo" and "BAR"). Values of hash keys is array index where results will be fed: + $tbl_ary_ref = $sth->fetchall_arrayref({ foo => 0, BAR => 1 });
Thanks for the suggestion. I don't see a good enough reason to add the feature you propose because the NAME_*_hash attributes can be used to map column names into column numbers. http://search.cpan.org/~timb/DBI/DBI.pm#NAME_lc_hash_(hash-ref,_read-only) $foo_idx = $sth->{NAME_lc_hash}{foo}; $bar_idx = $sth->{NAME_lc_hash}{bar}; $row = $sth->fetchrow_arrayref( [ $foo_idx, $bar_idx ] ); Tim.