title: Get recent items function with Doctrine
body: <p>New to Doctrine. I'm trying to build a "list recent items function". It <strong>should get all records newer than 3 months</strong> but <strong>if the result is less than 50 records it should get older ones until 50 is fetched</strong>. </p>
  
  <p>So if I have 100 records newer than three months I want to return all of them but nothing older. If I have 20 records from the last three months I want to return them and also the 30 most recent after that.</p>
  
  <p>How would one do this with Doctrine? I don't want to make two queries (is it even called that?) if possible.</p>
  
  <p>For now my EntityRepository just gets all records from the last three months as follows:</p>
  
  <pre><code>public function fetchRecent($from)
  {
      $criteria = new Criteria();
      $criteria-&gt;where($criteria-&gt;expr()-&gt;gte('created', $from));
  
      return $this-&gt;matching($criteria);
  }
  </code></pre>