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

后端 未结 1 1138
梦如初夏
梦如初夏 2021-02-20 05:57

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

I couldn\'t find any relevant info in the manual.

1条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-20 06:47

    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
      

    0 讨论(0)
提交回复
热议问题