symfony - How to make JOIN with OR expression in DQL? -


here sql equivalent of expect doctrine:

select c.* comments c   left join articles     on a.id = c.articles_id or a.translation = c.articles_id c.published = 1 , c.language = a.language 

the problem cannot make doctrine generate join operation or supposed be. if execute query following querybuilder object:

$qb->select('c')    ->from('project:comment', 'c')    ->leftjoin('c.article', 'a', 'with', 'a = c.article or a.translation = c.article')    ->where('c.published = true , c.language = a.language'); 

we receive following sql statement:

select   ... comments c0_  left join articles a0_ on c0_.articles_id = a0_.id  , (   a0_.id = c0_.articles_id or   a0_.translation = c0_.profiles_id ) c0_.published = 1 , c0_.language = a0_.language 

which not same initial query, with operator seems add additional conditions basic 1 instead of replacing whole condition.

is there way force doctrine output need? know may use native sql doubt convenient querybuilder. maybe there way extend doctrine normal join on implementation instead of odd join with?

doctrine doesn't implement because (as far understand @ least) not considered optimized enough sql.

see post precisions.

what intend appearantly done using union , other types of join.


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -