[Dbix-class] modifying join condition in search

Jon Schutz jon+dbix at youramigo.com
Thu Jul 19 11:55:33 GMT 2007


> 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
> 

First case produces a result row for every row in ph_topics.

Second case produces a result row only where watchers.user_id = 5.

One wonders though if the original poster wouldn't prefer the second
case.

In answer to the original question, I believe the parameter '5' could be
passed through as a bind variable; see 

http://search.cpan.org/~mstrout/DBIx-
Class-0.08003/lib/DBIx/Class/Manual/Cookbook.pod#Arbitrary_SQL_through_a_custom_ResultSource

-- 

Jon



More information about the Dbix-class mailing list