title: how to return an array of objects in zend framework 2?
body: <p>I am doing a query in zf2 and i get back a <code>object(Zend\Db\ResultSet\HydratingResultSet)</code> that i have to a <code>foreach</code> on, in order to get to the properties.</p>
  
  <p>I would like to get an array of objects by default.</p>
  
  <p>here is some code i have:</p>
  
  <p>factory</p>
  
  <pre><code>'address-mapper'  =&gt; function ($serviceManager) {
      $mapper = new Mapper\Address();
      $mapper-&gt;setDbAdapter($serviceManager-&gt;get('Zend\Db\Adapter\Adapter'));
      $mapper-&gt;setEntityPrototype(new Entity\Address);
      $mapper-&gt;setHydrator(new \Zend\Stdlib\Hydrator\ClassMethods);
  
      return $mapper;
  }
  </code></pre>
  
  <p>the query</p>
  
  <pre><code>public function fetchById()
  {
      $select = $this-&gt;getSelect()-&gt;where(array('id' =&gt; $Id));
      return $this-&gt;select($select);
  }
  </code></pre>
  
  <p>this gives me back:</p>
  
  <pre><code>object(Zend\Db\ResultSet\HydratingResultSet)[459]
        protected 'hydrator' =&gt; 
          object(Zend\Stdlib\Hydrator\ClassMethods)[415]
            protected 'underscoreSeparatedKeys' =&gt; boolean true
            private 'callableMethodFilter' =&gt; 
            ....
            ....
  </code></pre>
  
  <p>any ideas what i need to do?</p>