title: how works createQueryBuilder and leftJoin?
body: <p>I dont get how to make it work.</p>
  
  <p>I have:</p>
  
  <ul>
  <li>a table <code>partner</code> with fields <code>id</code> and <code>name</code></li>
  <li>a table <code>partner_address</code> with two fields: <code>id_partner</code> and <code>id_address</code></li>
  <li>a table <code>address</code> with fields <code>id</code> and external key <code>id_town</code> which references <code>town(id)</code></li>
  <li>a table <code>town</code> with fields <code>id</code>, a <code>name</code>, and <code>postal_code</code></li>
  </ul>
  
  <p>I want to select all partners that are in towns with specific <code>postal_code</code>
  This query works:</p>
  
  <pre><code>SELECT p.nom, v.nom
  FROM partner p
  JOIN partner_address pa
  ON pa.id_partner=p.id
  JOIN address a
  ON pa.id_address = a.id 
  JOIN town t
  ON a.id_town=t.id
  WHERE t.postal_code='13480';
  </code></pre>
  
  <p>Now I want to "translate" it into Doctrine 2 full syntax, following <a href="http://symfony.com/doc/current/book/doctrine.html" rel="nofollow">the documentation</a>.</p>
  
  <p>So I've made a custom repository:</p>
  
  <p><code>src/Society/Bundle/MyProjectBundle/Repository/PartnerRepository.php</code></p>
  
  <p>In this repository, I'm trying to create the corresponding function:</p>
  
  <pre><code>&lt;?php
  
  namespace HQF\Bundle\PizzasBundle\Repository;
  
  use Doctrine\ORM\EntityRepository;
  
  class PartenaireRepository extends EntityRepository
  {
      /**
       * Get all active partners from a given postal code.
       */
      public function findAllActiveByCp($cp)
      {
          return $this-&gt;createQueryBuilder('p')
              -&gt;where('p.dateVFin IS NULL')
              -&gt;andWhere('p.cp=:cp')
              -&gt;addOrderBy('p.cp', 'DESC')
              -&gt;setParameter('cp', $cp);
      }
  }
  </code></pre>
  
  <p>Nota: the query in the code is <strong>not the right one</strong> but this code works in another custom repository I've made, so I'm trying to start from this code.</p>
  
  <p>I'm trying something like this but it doesn't work:</p>
  
  <pre><code>public function findAllActiveByCp($cp)
  {
      $qb = $this-&gt;createQueryBuilder('p');
      return $qb
          -&gt;leftJoin('partner_address pa ON pa.id_partner=p.id')
          -&gt;leftJoin('address a ON pa.id_address = a.id')
          -&gt;leftJoin('town t ON a.id_ville=t.id')
          -&gt;where('p.dateVFin IS NULL')
          -&gt;andWhere('t.cp=:cp')
          -&gt;addOrderBy('t.cp', 'DESC')
          -&gt;setParameter('cp', $cp);
  }
  </code></pre>
  
  <p>I get this error:</p>
  
  <blockquote>
    <p>Warning: Missing argument 2 for Doctrine\ORM\QueryBuilder::leftJoin(),
    called in
    /blabla/Repository/PartenaireRepository.php
    on line 18 and defined in
    /blabla/symfony/vendor/doctrine/orm/lib/Doctrine/ORM/QueryBuilder.php
    line 767</p>
  </blockquote>