Search code examples
phpdoctrine-ormdoctrine

What is the difference between WITH and ON in Doctrine Join condition type?


I'm searching for a better explanation about the difference between WITH and ON condition type for the doctrine clausure.

I'm finding the documentation about this very poor and I'm still in doubt.


Solution

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