[Dbix-class] equivalent of DBI's selectall_hashref in DBIC?

Ash Berlin ash_cpan at firemirror.com
Fri Dec 19 19:59:51 GMT 2008


On 19 Dec 2008, at 19:34, Fernan Aguero wrote:

> Hi,
>
> I'd like to fetch data from DBIC in the form of a hash (i.e. indexed
> by a key, say a PK) instead of in the form of an array, which is the
> native structure of a DBIC RS.
>
> In plain DBI, I can do it using selectall_hashref, and specifying the
> column to use as the hash key.
>
> Can I do something like this in DBIC? I've looked through the docs and
> couldn't find anything, but perhaps there's something very obvious
> that is elluding me ...
>
> Cheers,


my $hash = {};
$hash{$_->col} = $_ for ($rs->all);

Its just perl.



More information about the DBIx-Class mailing list