You meant related_resultset, there is no such thing as a recordset in DBIC.
Also why don't you use find if you want to fetch a single result object from 
the database?
You can use HRI with find too if that was the reason.

Am 2012-01-23 16:20, schrieb will trillich:
Whoops--

On Mon, Jan 23, 2012 at 9:19 AM, will trillich 
<[email protected]<mailto:[email protected]>> wrote:
Can you use related_resultset or search_related?

# See https://metacpan.org/module/DBIx::Class::ResultSet#related_resultset
$table4_rs = 
$table1_rs->search_related_rs('table2')->search_related_rs('table4');

I meant

$table4_rs = 
$table1_rs->related_recordset('table2')->related_recordset('table4');

:)

# See https://metacpan.org/module/DBIx::Class::Manual::Features#search_related
$table4_rs = $table1_rs
   ->search_related_rs( table2 => { fld => 'blah' } )
   ->search_related_rs('table4' => { xyz => 'pdq' } );

You can also inject utility methods into your schema definitions to return 
various related recordsets as well.



On Mon, Jan 23, 2012 at 8:55 AM, Roland Philibert 
<[email protected]<mailto:[email protected]>> wrote:
I manage to go through the database from a given primary key by doing in
the controller:

...
  my $pk = '1';
  my $t1 = $c->model('DB')->resultset('Table1')->search({ table1id =>
$pk,},
                                                        {result_class
=> 'DBIx::Class::ResultClass::HashRefInflator',});

  my $rs_t2 = $c->model('DB')->resultset('Table2')->search({
'table3s.ftable1id' => $pk ,},
                                                        {join => {
'table3s'},

result_class => 'DBIx::Class::ResultClass::HashRefInflator',});

  while ( my $subrs = $rs_t2->next ) {
     $subrs = $c->model('DB')->resultset('Table2')->search(   {
table2id => $subrs->{table2id},  },   { } );
     push @t2 , $subrs;
  }
  $c->stash(
              t1 => [ $t1 ] ,
              rst2 => \@t2
           );
  $c->detach($c->view("HTML"));
}



..so that's a lof of searches,
The first one is to get the info related to table1.
The second one is to get all related table2 items related to pk of
table1.
The loop create a search for each items of the second search to get
items from table4.

....keep thinking that there must be a simpler way?
Any help greatly appreciated.

Thanks


















Aptina (UK) Limited, Century Court, Millennium Way, Bracknell, Berkshire, RG12 
2XT. Registered in England No. 06570543.

This e-mail and any attachments contain confidential information and are solely 
for the review and use of the intended recipient. If you have received this 
e-mail in error, please notify the sender and destroy this e-mail and any 
copies.


_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class<http://irc.perl.org#dbix-class>
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]



--
"We act as though comfort and luxury were the chief requirements of life, when all 
that we need to make us happy is something to be enthusiastic about." -- Albert 
Einstein




--
"We act as though comfort and luxury were the chief requirements of life, when all 
that we need to make us happy is something to be enthusiastic about." -- Albert 
Einstein




_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]


*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
T-Systems Austria GesmbH Rennweg 97-99, 1030 Wien
Handelsgericht Wien, FN 79340b
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
Notice: This e-mail contains information that is confidential and may be 
privileged.
If you are not the intended recipient, please notify the sender and then
delete this e-mail immediately.
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]

Reply via email to