[Catalyst] has something like DBI's fetchrow_hashref()?

Sébastien Wagener sebastien.wagener at gmail.com
Mon Dec 18 13:49:28 GMT 2006


On Mon, 2006-12-18 at 14:11 +0100, Robert 'phaylon' Sedlacek wrote:
> Wan wrote:
> > hello everyone,
> > 
> > I use DBIx::Class in my Catalyst project.
> 
> As a note: This is _not_ a Catalyst question! Except that you access
> your model via Catalyst, it is all only DBIx-Class here. DBIC has
> separete documentation and a separate mailinglist.
> 
> > my $cfg = $c->model('RTDB::Config')->search({Name =>
> > $c->req->param("name")})->first;
> > 
> > ......
> > $cfg->Name;
> > $cfg->Value;
> > 
> > I want to get a hash ref that like this
> > 
> > .....
> > $cfg->{Name};
> > $cfg->{Value};
> 
> Look at the 'get_columns' method in DBIx::Class::Row. This should be
> what you're looking for.
> 
If you REALLY need hashrefs instead of objects (for speed purposes or
whatever), have a look at
http://search.cpan.org/~bricas/DBIx-Class-0.07003/lib/DBIx/Class/Manual/Cookbook.pod#Skip_object_creation_for_faster_results
But you should know what you are doing in this case.
If you don't, get_columns is probably what you want.




More information about the Catalyst mailing list