On 11 Dec 2006, at 01:49, brett gardner wrote:

Is there any reason that you cannot search using relationship accessors?

eg

   my $respondent =
   $schema->resultset('SurveyRespondent')->find($respondent_id);

   my $questions =
   $schema->resultset('SurveyQuestion')->search({foo=>'bar'});

   while (my $question = $questions->next){
       my $answer =
$respondent->search_related('answers',{question_id=> $question_id})->next;
       print $answer->display_answer if ($answer);
   }


Which means I need to know the foreign keys mapping answers to questions. What I would like to be able to do is replace the "my $answer ..." line with the following.

my $answer = $respondent->search_related('answers',{question=> $question})->next; #question being a relationship defined in the SurveyAnswer object.

Is this something that is on the todo list, or has it been looked at and deemed to complicated and slow?

It's intended, but it's harder than it looks to implement generally hence not having been done so far.

--
Matt S Trout, Technical Director, Shadowcat Systems Ltd.
Offering custom development, consultancy and support contracts for Catalyst, DBIx::Class and BAST. Contact mst (at) shadowcatsystems.co.uk for details. + Help us build a better perl ORM: http://dbix- class.shadowcatsystems.co.uk/ +



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

Reply via email to