title: How to select distinct query using symfony2 doctrine query builder?
body: <p>I have this symfony code where it retrieves all the categories related to a blog section on my project:</p>
  
  <pre><code>$category = $catrep-&gt;createQueryBuilder('cc')
      -&gt;Where('cc.contenttype = :type')
      -&gt;setParameter('type', 'blogarticle')
      -&gt;getQuery();
  
  $categories = $category-&gt;getResult();
  </code></pre>
  
  <p>This works, but the query includes duplicates:</p>
  
  <pre><code>Test Content
  Business
  Test Content
  </code></pre>
  
  <p>I want to use the <code>DISTINCT</code> command in my query.  The only examples I have seen require me to write raw SQL. I want to avoid this as much as possible as I am trying to keep all of my code the same so they all use the QueryBuilder feature supplied by Symfony2/Doctrine.</p>
  
  <p>I tried adding <code>distinct()</code> to my query like this:</p>
  
  <pre><code>$category = $catrep-&gt;createQueryBuilder('cc')
      -&gt;Where('cc.contenttype = :type')
      -&gt;setParameter('type', 'blogarticle')
      -&gt;distinct('cc.categoryid')
      -&gt;getQuery();
  
  $categories = $category-&gt;getResult();
  </code></pre>
  
  <p>But it results in the following error:</p>
  
  <blockquote>
    <p>Fatal error: Call to undefined method Doctrine\ORM\QueryBuilder::distinct()</p>
  </blockquote>
  
  <p>How do I tell symfony to select distinct?</p>