title: Laravel Doctrine ordering a paginated result
body: <p>I'm new to Doctrine and I've been starting to use it for a personal project. I'm using the laravel-doctrine libraries to get it working with laravel.</p>
  
  <p>Unfortunately, when I attempt to order a paginated query I see the following error:</p>
  
  <pre><code>An exception occurred while executing 'SELECT DISTINCT id_0 FROM (SELECT 
  t0_.id AS id_0, t0_.title AS title_1, t0_.slug AS slug_2, t0_.views AS  
  views_3, t0_.replies AS replies_4, t0_.created_at AS created_at_5,  
  t0_.updated_at AS updated_at_6, p1_.id AS id_7, p1_.body AS body_8,  
  p1_.created_at AS created_at_9, p1_.updated_at AS updated_at_10,  
  p1_.deleted_at AS deleted_at_11, c2_.id AS id_12, c2_.name AS name_13,  
  c2_.slug AS slug_14, c2_.created_at AS created_at_15, c2_.updated_at AS  
  updated_at_16 FROM topics t0_ LEFT JOIN posts p1_ ON t0_.id = p1_.topic_id  
  LEFT JOIN categories c2_ ON t0_.category_id = c2_.id) dctrn_result ORDER BY  
  created_at_5 ASC LIMIT 10 OFFSET 0':
  
  SQLSTATE[HY000]: General error: 3065 Expression #1 of ORDER BY clause is not  
  in SELECT list, references column 'dctrn_result.created_at_5' which is not  
  in SELECT list; this is incompatible with DISTINCT
  </code></pre>
  
  <p>The actual code that causes this error is as follows:</p>
  
  <pre><code>    public function findAll($results = 10, $pageName = 'page') {
          $query = $this-&gt;createQueryBuilder('t')
              -&gt;select('t', 'f', 'c')
              -&gt;leftJoin('t.first', 'f', 'ON')
              -&gt;leftJoin('t.category', 'c', 'ON')
              -&gt;orderBy('t.createdAt', 'asc')
              -&gt;getQuery();
  
          return $this-&gt;paginate($query, $results, $pageName);
      }
  </code></pre>
  
  <p>I am trying to select a list of topics, with their category and first post all while ordered by the topic created_at date. </p>
  
  <p>I've spent some time looking into this but as of yet have been unable to figure out what's going on, is there another way I should be doing this or is my code incorrect?</p>