What is the difference between JOIN ON and JOIN WITH in Doctrine2?

一个人想着一个人 提交于 2020-12-02 07:07:57

问题


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]
  1. 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
    
  2. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!