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

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -