title: DBAL Symfony 2 SQL Statements
body: <p>I'm currently playing around with symfony and DBAL to collect data from an external database.</p>
  
  <pre><code>        $conn = $this-&gt;get('database_connection');
  
          $users = $conn-&gt;fetchAll('SELECT * FROM cms_clients');
  
          print_r($users);
  </code></pre>
  
  <p>The code above works fine, but I need to do more complicated queries, and the only documentation I can find is <a href="http://doctrine-dbal.readthedocs.org/en/latest/reference/query-builder.html" rel="nofollow noreferrer">http://doctrine-dbal.readthedocs.org/en/latest/reference/query-builder.html</a> </p>
  
  <p>The documentation is really good but i'm not sure how i would implement the code bellow in my example.</p>
  
  <p><code>$queryBuilder
      -&gt;select('u.id', 'u.name')
      -&gt;from('users', 'u')
      -&gt;where('u.email = ?')
      -&gt;setParameter(0, $userInputEmail)
  ;</code></p>
  
  <p><strong>Solution, thanks for replays anyway</strong> </p>
  
  <blockquote>
  <pre><code>      $conn = $this-&gt;get('database_connection');
  </code></pre>
  </blockquote>
  
  <pre><code>        $parms = array($DataSource, 'STORE');
  
          $query = "SELECT * FROM cms_things LEFT JOIN cms_stores ON cms_things.id=cms_stores.thing_id WHERE client_id = ? AND type = ? ";
  
          $users = $conn-&gt;fetchAll($query, $parms);
  </code></pre>