title: Symfony/Doctrine: fetching data as object
body: <p>In Symfony, I use Doctrine_Query to query the database</p>
  
  <pre><code>$q = Doctrine_Query::create()
        -&gt;from('User u')
        -&gt;where('u.username = ?', $username)
        -&gt;andWhere('u.password = ?', $password);
  $user = $q-&gt;fetchArray();
  </code></pre>
  
  <p>The problem is that the results are stored in an array.  Is there any way that I can make it fetch an object instead of an array?</p>
  
  <p>Also, are there any other ways that I can query the database in Symfony or do I have to use Doctrine's functions?</p>