Uploaded image for project: 'Doctrine 1'
  1. Doctrine 1
  2. DC-501

Join and WITH keywords : documentation is confusing


    • Type: Improvement
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 1.1.6
    • Fix Version/s: None
    • Component/s: Documentation
    • Labels:


      Your documentation makes no sense to me on the usage of the WITH keyword


      $q = Doctrine_Query::create()
        ->select('u.id, p.id')
        ->from('User u')
        ->leftJoin('u.Phonenumbers p WITH u.id = 2');

      Get Users and the phone numbers if any of the user 2 (we could indeed need that kind of query)

      I guess this kind of example query is better

      // Documentation
      Get users and their mobile phone numbers if any

      $q = Doctrine_Query::create()
        ->select('u.id, p.id')
        ->from('User u')
        ->leftJoin('u.Phonenumbers p WITH p.type = ?', 'mobile');

      you can expect this SQL

      u.id AS u__id, 
      p.id AS p__id 
      FROM User u 
      LEFT JOIN Phonenumbers p ON u.id = p.user_id AND p.type = 'mobile'

      // Still in the documentation
      Be aware that this query is different of

      $q = Doctrine_Query::create()
        ->select('u.id, p.id')
        ->from('User u')
        ->leftJoin('u.Phonenumbers p')
        ->where('p.type = ?', 'mobile')

      because you will strip away the users who do not have a mobile phone number

      Also the second example is more confusing ...

      $q = Doctrine_Query::create()
          ->from('User u')
          ->leftJoin('u.Groups g')
          ->innerJoin('u.Phonenumbers p WITH u.id > 3')
          ->leftJoin('u.Email e');

      Means : Get Users (who HAVE Phonenumbers (innerJoin)) with their potential (leftJoin) Groups, potential (leftJoin) Emails, and their Phonenumbers
      but not for the Users 1, 2 and 3

      Not really the straight forward example we can expect in a documentation

      Best regards


        There are no comments yet on this issue.


          • Assignee:
            jwage Jonathan H. Wage
            julien.b Julien B.
          • Votes:
            0 Vote for this issue
            0 Start watching this issue


            • Created: