title: How to manually query from the database using symfony2 and doctrine
body: <p>I'm trying to query the database in my user repository like this (symfony2):</p>
  
  <pre><code>namespace Doobin\UserBundle\Entity;
  
  use Doctrine\ORM\EntityRepository;
  
  class UserRepository extends EntityRepository
  {
  public function pageAccess($User=1,$Page='_home')
  {
      $query="SELECT `user` FROM `vu001_user_permission` WHERE `user` = '$User' AND `path`='$Page'";
      $conn = Doctrine_Manager::getInstance()-&gt;connection();
      $stmt = $conn-&gt;prepare($query);
      $stmt-&gt;execute();
      return $stmt;
  }
  </code></pre>
  
  <p>But it won't work.
  It stop working when it arives at the live
  <code>$conn = Doctrine_Manager::getInstance()-&gt;connection();</code></p>
  
  <p>I copied that from the symfony website tuturial.</p>
  
  <p>I Also tried this too:</p>
  
  <pre><code>$em = $this-&gt;getDoctrine()-&gt;getEntityManager();
      $connection = $em-&gt;getConnection();
      $statement = $connection-&gt;prepare("SELECT `user` FROM `vu001_user_permission` WHERE `user` = '$User' AND `path`='$Page'");
      $statement-&gt;execute();
      $results = $statement-&gt;fetchAll();
  </code></pre>
  
  <p>It stop working when it arive to line <code>$em = $this-&gt;getDoctrine()-&gt;getEntityManager();</code></p>
  
  <p>And tried this too:</p>
  
  <pre><code>namespace Doobin\UserBundle\Entity;
  
  use Doctrine\ORM\EntityRepository;
  
  class UserRepository extends EntityRepository
  {
  public function pageAccess($User=1,$Page='_home')
  {
  return $this-&gt;getEntityManager()
          -&gt;createQuery(
              'SELECT p FROM UserBundle:User p ORDER BY p.name ASC'
          )
          -&gt;getResult();
  }
  }
  </code></pre>
  
  <p><code>$this-&gt;getEntityManager()</code> now working, please help I'm so confiused.
  I checked everything.</p>
  
  <p>Am I missing anything?</p>