title: Symfony2, JOINS with doctrine2 or sql
body: <p>I have a question about symfony2.</p>
  
  <p>I have a project and I am using databases with it. I use for the most part Doctrine2 and entity classes. I like the entity class object database stuff, very handy etc.</p>
  
  <p>My question is, is there a way to perform normal SQL in symfony? I always get an exception when I try to use standard SQL. I am having trouble with joins in doctrine2, so i would rather use normal SQL for that.</p>
  
  <p>My join would look like this in SQL:</p>
  
  <pre><code>SELECT DISTINCT Document . * 
  FROM Document
  INNER JOIN DocumentGruppe ON Document.id = DocumentGruppe.dokId
  INNER JOIN UserGruppe ON DocumentGruppe.gruppenId = UserGruppe.gruppenId
  WHERE UserGruppe.userId =9
  </code></pre>
  
  <p>The where clause at the end is just for testing. If I use doctrine with it's DQL it always says that there is an exception: <code>The Variable DocumentGruppe was not defined before</code>.</p>
  
  <p>Here is my DQL query:</p>
  
  <pre><code>    $test = $em-&gt;createQuery(
          'SELECT DISTINCT d
          FROM AcmeDocumentBundle:Document d
          INNER JOIN DocumentGruppe dg ON d.id = dg.dokId
          INNER JOIN UserGruppe ug ON dg.gruppenId = ug.gruppenId
          WHERE ug.userId =9
          '
      );
  </code></pre>
  
  <p>Does anyone know a workaround or a way to use this doctrine2 stuff to work with joins?</p>