title: How to set Array Object Prototype for a Result Set of an Sql statement created with Sql object‏ in ZF2
body: <p>I want to use the Sql object in my model to query the database. I have an entity object lets say Person and person object has <code>exchangeArray()</code> method. I want to set this Person object to be an <code>Array Object Prototype</code> of the ResultSet for my sql queries.</p>
  
  <p>I research how to do this but the only information I found is how to set Array Object Prototype to a <code>ResultSet</code> object assigned to a <code>Zend\Db\TableGateway\TableGateway</code>.</p>
  
  <pre><code>$personEntity = new PersonEntity();
  $resultSet = new \Zend\Db\ResultSet\ResultSet();
  $resultSet-&gt;setArrayObjectPrototype($personEntity);
  $db = $sm-&gt;get('Zend\Db\Adapter\Adapter');
  $table = new \Zend\Db\TableGateway\TableGateway('table', $db, null, $resultSet);
  </code></pre>
  
  <p>My question is how can I set <code>PersonEntity</code> object to represent rows of my database that are return from a <code>Zend\Db\Sql\Sql</code> objects?</p>
  
  <p>Thanks in advance,</p>
  
  <p>Steve</p>