[Dbix-class] search_literal

Matt S Trout dbix-class at trout.me.uk
Mon Sep 24 00:54:16 GMT 2007


On Mon, Sep 24, 2007 at 09:04:51AM +1000, brett gardner wrote:
> Well
> 
> Is there anyway to do the following.
> 
> I have a Respondent record, which has a one to many relationship with 
> Answer records.
> 
> I want to be able to get a set of Respondents who answered a particular 
> way and I first tried do it like
> 
> my $rs = $schema->resultset('Respondent')->search(
> 	{
> 		'answers.question_id'=>$foo,
> 		'answers.answer'=>$bar
> 	},
> 	{
> 		join=>'answers',
> 	}
> );
> 
> 
> Which works, but when you call search on this resultset again, ie, 
> searching withing that subset, it fails eg
> 
> $rs = $rs->search(
> 	{
 		'answers_2.question_id'=>$foo_1,
 		'answers_2.answer'=>$bar_1,
> 	},{
 		join=> [ 'answers', 'answers' ],
> 	}
> );

See the resultset docs for more info about how DBIC handles multiple aliases.

-- 
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director                    http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://chainsawblues.vox.com/            http://www.shadowcat.co.uk/servers/



More information about the DBIx-Class mailing list