title: Expect one or no result from a doctrine query builder, what should I use?
body: <p>I have this method:</p>
  
  <pre><code>public function getMonth ($month_name)
      {
          $q = $this-&gt;createQueryBuilder('m');
  
          $q-&gt;select('m')
              -&gt;where('m.name = :name')    
              -&gt;setParameter('name', $month_name);
  
          return $q-&gt;getQuery()-&gt;getResult();
      }
  </code></pre>
  
  <p>From it I expect to find one month or 0 months. I use this method in this way in my Controllers:</p>
  
  <pre><code>$month = $em-&gt;getRepository('EMExpensesBundle:Month')
                  -&gt;getMonth($this-&gt;findMonth());
  
              $month-&gt;setSpended($item-&gt;getPrice());
  </code></pre>
  
  <p>I tried this with <code>getSingleResult()</code> and everything was perfect untill I came across a case when no month was found and everything failed really bad!</p>
  
  <p>Then I tried with <code>getResult()</code>, but it returns an array and then  </p>
  
  <pre><code>$month-&gt;setSpended($item-&gt;getPrice());
  </code></pre>
  
  <p>is said to be called on a non-object and to fix it I should use everywhere</p>
  
  <pre><code>$month[0]-&gt;setSpended($item-&gt;getPrice());
  </code></pre>
  
  <p>Is there a more elegant way to achieve this without the need to add unnecesary [0] index everywhere?</p>