title: Symfony2 QueryBuilder not working
body: <p>I am learning Symfony2 with Doctrine2</p>
  
  <p>I am trying to use <code>createQueryBuilder()</code>, but I get an error when I try to call the results in my <code>indexController</code>.</p>
  
  <p>The Error is:</p>
  
  <pre><code>Catchable fatal error: Object of class API\TestBundle\TestDoctrine\Repository\TestRepo could not be converted to string in /Users/tomasz.koprowski/Dev/jv-api/src/API/TestBundle/Controller/IndexController.php on line 60
  </code></pre>
  
  <p>My TestRepo:</p>
  
  <pre><code>&lt;?php
  
  namespace API\TestBundle\TestDoctrine\Repository;
  
  use API\TestBundle\TestDoctrine\DatabaseRepository;
  use Doctrine\DBAL\Connection;
  use Psr\Log\LoggerInterface;
  
  
  class TestRepo extends DatabaseRepository{
  
      protected $test = array();
  
      public function __construct(
          Connection $connection,
          LoggerInterface $logger
      ){
          parent::__construct($connection, $logger);
      }
  
      public function getTestData()
      {
  
          $check = $this-&gt;db-&gt;createQueryBuilder()
  
              -&gt;select('test.user_name')
              -&gt;from('test');
  
          $this-&gt;test = $check-&gt;execute()-&gt;fetchAll(\PDO::FETCH_ASSOC);
          return $this-&gt;test;
      }
  } 
  </code></pre>
  
  <p>My Controller:</p>
  
  <pre><code>&lt;?php
  namespace API\TestBundle\Controller;
  
  use Symfony\Component\HttpFoundation\Request;
  use Symfony\Component\HttpFoundation\JsonResponse;
  
  use API\TestBundle\TestDoctrine\Repository\TestRepo;
  
  class IndexController
  {
      public $test;
  
      public function __construct(
          TestRepo $test
      ) {
          $this-&gt;$test = $test;
      }
  
      public function testDoctrineAction()
      {
         return new JsonResponse($this-&gt;test-&gt;getTestData());
      }
  }
  </code></pre>
  
  <p>Any Idea where I am going wrong with this one?</p>