title: How to get partial result from doctrine query builder
body: <p>I have a product entity in which it has an array as attributes:</p>
  
  <pre><code>     /**
       * @ORM\OneToMany(targetEntity="Shopious\MainBundle\Entity\ProductPicture", mappedBy="product", cascade={"persist","remove"})
       */
      protected $pictures;
  
      /** 
      * @Accessor(getter="getCover") 
      */
      private $cover;
      public function getCover()
      {
          if($this-&gt;pictures-&gt;count() &gt; 0) {
              return $this-&gt;pictures[0];
          }
          return new ProductPicture();
      }
  </code></pre>
  
  <p>Now in my query builder, I have the following code:</p>
  
  <pre><code> $query = $em-&gt;createQueryBuilder()-&gt;select('p')
              -&gt;from("SiteMainBundle:Product", 'p')
              -&gt;innerJoin('p.category', 'c')
              -&gt;innerJoin('p.shop', 'shop')
              ;
  </code></pre>
  
  <p>The issue here is that I don't want to be selecting all of p's attribute. So I only wanted to get the first ProductPicture in the pictures array (in my case above it's similar to the getCover() method). How do I do this?</p>
  
  <p>So far I can filter out the the partial attributes that I want by doing:</p>
  
  <pre><code> $query = $em-&gt;createQueryBuilder()-&gt;select('p.name, p.id')
                  -&gt;from("SiteMainBundle:Product", 'p')
                  -&gt;innerJoin('p.category', 'c')
                  -&gt;innerJoin('p.shop', 'shop')
                  -&gt;innerJoin('p.pictures', 'pictures')
                  ;
  </code></pre>
  
  <p>so in the example above I have done inner joined on the pictures, but how do I get the first element from here?</p>
  
  <p>In conclusion, my question is how do I select/query the first ProductPicture in the pictures array using the query builder? Because when I do:</p>
  
  <p>$query = $em->createQueryBuilder()->select('p')</p>
  
  <p>it returns the whole product attributes, but I don't want the whole product attributes.. I only wanted some of them, such as the id, name, etc. However one of the product attributes is actually an entity (which is the ProductPicture), so how do I return this in the select statement?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Here's a SQL equivalent on how the pictures should be inner joined:</p>
  
  <pre><code>SELECT * 
  FROM  `product` 
  JOIN  `product_picture` ON  `product`.id =  `product_picture`.product_id
  WHERE  `product`.id =100
  LIMIT 1
  </code></pre>