Pedro Melo wrote: > > Hi, > > > > I have a relation defined like this: > > > > in Topics.pm: > > > > __PACKAGE__->has_many( watchers => 'PH::S::Watching', > > { 'foreign.topic_id' => 'self.id' }); > > > > In a search() I need to do a left join between Topics and Watching, > > but I need to add another statement to the join condition. > > > > If I use join => 'watchers', > > > > the SQL generated is: > > > > ph_topics me LEFT JOIN ph_watchers watchers ON ( watchers.topic_id = > > me.id ) > > > > but I need it to be like this: > > > > ph_topics me LEFT JOIN ph_watchers watchers ON ( watchers.topic_id = > > me.id AND watchers.user_id = 5 ) > > > > (where 5 wlll be a parameter). > > > > Before I jump to the 'from' attribute, can this be done with join? I > > could not figure it out... > > > > Best regards,
Why do you need it to be in the join? whats the difference between: ph_topics me LEFT JOIN ph_watchers watchers ON ( watchers.topic_id = me.id AND watchers.user_id = ? ) and ph_topics me LEFT JOIN ph_watchers watchers ON ( watchers.topic_id = me.id ) WHERE watchers.user_id = 5 _______________________________________________ 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/dbix-class@lists.rawmode.org/