问题
What is the difference between JOIN ON and JOIN WITH in Doctrine2?
I couldn't find any relevant info in the manual.
回答1:
ON
replaces the original join condition,WITH
adds a condition to it.
Example:
[Album] ---OneToMany---> [Track]
Case One
DQL
FROM Album a LEFT JOIN a.Track t WITH t.status = 1
Will translate in SQL
FROM Album a LEFT JOIN Track t ON t.album_id = a.id AND t.status = 1
Case Two
DQL
FROM Album a LEFT JOIN a.Track t ON t.status = 1
Will translate in SQL
FROM Album a LEFT JOIN Track t ON t.status = 1
来源:https://stackoverflow.com/questions/13137908/what-is-the-difference-between-join-on-and-join-with-in-doctrine2