[Dbix-class] Re: extracting all data from ResultSet
Dagfinn Ilmari Mannsåker
ilmari at ilmari.org
Mon Jun 4 01:38:59 GMT 2007
Joss Shaw <jossblowing at yahoo.co.uk> writes:
> Hi there,
> Im using some crusty template engine, the only one
> installed on my target machine which means I need to
> send all data to the engine in a hashref format only -
> I can't call object methods.
>
> I've got a table which has quite a few relationships
> defined on it.
[…]
> Is it possible to pull all data from a related table like this ? If
> so,please please tell me - am so stuck. big big thanks for anything,
Take a look at the HashRefInflator result class:
<http://search.cpan.org/~jrobinson/DBIx-Class-0.07999_02/lib/DBIx/Class/ResultClass/HashRefInflator.pm>
To get the related columns as well, just use prefetch:
my $rs = $schema->resultset('MyTable')
my $search_rs = $rs->search({ key => $value },
{ prefetch => 'has_many_relationship' });
$search_rs->result_class('DBIx::Class::ResultClass::HashRefInflator');
$hashref = $search_rs->first;;
--
ilmari
"A disappointingly low fraction of the human race is,
at any given time, on fire." - Stig Sandbeck Mathisen
More information about the Dbix-class
mailing list