title: How to get an associative array from a ResultSetMapping?
body: <p>I'm working on a Symfony2 project (Doctrine) and I would like to get a simple associative array from a ResultSetMapping object.</p>
  
  <p>This is my request :</p>
  
  <pre><code>$rsm = new ResultSetMapping;
  
  //$rsm-&gt;addIndexByScalar('name');
  $rsm-&gt;addScalarResult('name', 'name');
  $rsm-&gt;addScalarResult('rate', 'rate');
  
  return $this-&gt;_em-&gt;createNativeQuery(sprintf('
                  SELECT DISTINCT t1.sold_drug as name, (COUNT(*)/(SELECT COUNT(*) FROM Transaction t WHERE t.sold_drug != ""))*100 as rate
                           FROM Transaction t1
  
                   WHERE t1.sold_drug != "" AND t1.prescribed_but_not_sold != "No"
                   GROUP BY name
                   ORDER BY rate DESC', $this-&gt;getFilterQuery()), $rsm)-&gt;getResult();
  </code></pre>
  
  <p>So I would like to get an associative array such as :</p>
  
  <pre><code>array('nameA' =&gt; 10, 'nameB' =&gt; 2, ...);
  </code></pre>
  
  <p>I tried to add ScalarResult / ScalarIndex but no success !</p>
  
  <p>Any idea ?
  Thanks !</p>