title: Convert Zend\Db\ResultSet\HydratingResultSet to Array of Objects
body: <p>In my Mapper class I'm extending <code>AbstractDbMapper</code> from <code>ZfcBase</code> to fetch rows from the database. A simple example would be code like this:</p>
  
  <pre><code>class MyMapper extends AbstractDbMapper
  {
  
      //...
  
      public function fetchAll() {
          $select = $this-&gt;getSelect();
          return $this-&gt;select($select); // returns HydratingResultSet
      }
  }
  </code></pre>
  
  <p>The problem is that <code>$this-&gt;select()</code> returns a <code>Zend\Db\ResultSet\HydratingResultSet</code> (containing the needed and hydrated objects). But I would like to return an array of these objects instead of a <code>HydratingResultSet</code> containing the objects.</p>
  
  <p>The first thing to look at would be <code>HydratingResultSet::toArray()</code> but this returns a multidimensional array instead of an array of objects.</p>
  
  <p>So I chose to do it by hand:</p>
  
  <pre><code>public function fetchAll() {
          $select = $this-&gt;getSelect();
  
          $results = array();
          foreach ($this-&gt;select($select) as $object) {
              $results[] = $object;
          }
          return $results; // returns array of needed objects
  }
  </code></pre>
  
  <p>This works but looks ugly in every fetch method. Do I have to modify the code from select() to get the wanted behavior or is there an easier way?</p>
  
  <p>Btw: Is it even recommended to return an array or convert it like this? Thanks for your help!</p>