title: Doctrine Many To Many Inner Join
body: <p>I'm trying to get manyToMany relationship with Doctrine and symfony. 
  I'm new at Doctrine and Symfony. I came from Zend framework.</p>
  
  <p>I've created the 3 tables: 
  Post, PostCategory and junction table PostToCategory as you can see below.</p>
  
  <p><a href="https://i.stack.imgur.com/QOvCz.png" rel="nofollow"><img src="https://i.stack.imgur.com/QOvCz.png" alt="Tables example"></a></p>
  
  <p>My goal is to do inner join and to get for every post its categories.
  This is what I've done so far:</p>
  
  <p>//CMS/GBundle/Entity/PostContent</p>
  
  <pre><code>class PostContent
  {
  
      /**
       * @ORM\ManyToMany(targetEntity="CMS\GBundle\Entity\PostCategory", inversedBy="posts")
       * @ORM\JoinTable(name="post_to_category")
       */
      protected $categories;
  
      public function __construct()
      {
          $this-&gt;categories = new ArrayCollection();
      }
  </code></pre>
  
  <p>//CMS/GBundle/Entity/PostCategory</p>
  
  <pre><code>class PostCategory
  {
  
      /**
       * @ORM\ManyToMany(targetEntity="CMS\GBundle\Entity\PostContent", mappedBy="categories")
       */
      protected $posts;
  
      public function __construct()
      {
          $this-&gt;posts = new ArrayCollection();
      }
  </code></pre>
  
  <p>I would like now to create function that returns me joined data Post->PostCategories. </p>
  
  <p>Where should I create function ? in PostToCategory Repository ? or somewhere else ? How should my query look like ?</p>
  
  <p>I've tried a lot of options and I passed all the possible questions on Stack but I could not get it done..</p>
  
  <p>Thanks in advance!</p>
  
  <p>Update: </p>
  
  <p><a href="https://i.stack.imgur.com/BPCH0.png" rel="nofollow"><img src="https://i.stack.imgur.com/BPCH0.png" alt="This is what i get when do findAll"></a></p>
  
  <p>This is what i get when i do findAll method on PostContent repository.</p>