What is the difference between WITH and ON in Doctrine Join condition type?
Using the ON
condition type requires having a relation between joined entities.WITH
can be used if no relation exists between entities, but we should satisfy some conditions using the other side of join.
In some contexts, where ON
and WITH
condition types are possible, I think that ON
is interpreted faster and executed by almost DBMS.
In my opinion it's kind of a left over from doctrine 1.
Back then ON
was used to redefine the join conditions of relations, whereas WITH
was used to add more join conditions to the default one.
Now in doctrine 2 I have never seen a situation where ON
can be used. In fact using ON
always ends up in an exception saying you should use WITH
.
Right now WITH
can be used to add join conditions to the default one defined in a relation or, if no relation exists between two entities, define the join condition.