title: Zend Framework: How to unset data rows in a Zend_Db_Table_Rowset object
body: <p>I would like to iterate over the data rows stored in a Zend_Db_Table_Rowset object and then drop/unset some of the rows, if they don't fulfil certain criteria.</p>
  
  <p>I could use toArray() to get only the data rows from the object and then it would be easy to unset the rows I don't need. But since I want to keep my object for further use I don't want to do that.</p>
  
  <p>Of course one solution would be to adjust my query in order to retrieve only what I need, but that's not possible in this scenario. At least I wouldn't know how.</p>
  
  <p>I tried the following which didn't work:</p>
  
  <pre><code>foreach ($rowset as $key =&gt; $row)
  {
      if (!$condition == satisfied)
      {
          unset($rowset[$key]);
      }
  }
  </code></pre>
  
  <p>And of course it doesn't work, since there is no $rowset[$key]... the data is stored in a subarray [_data:protected] but unset $rowset[_data:protected][$key] didn't work either.</p>
  
  <p>Maybe my conception of a rowset object (or the representation of objects in general) is not mature enough to understand what I'm doing. Any clarification and tips would be welcome!</p>
  
  <p>[EDIT] 
  $row->delete is NOT an option, I don't want to delete the row from the database!
  I don't want to create an array first, if I wanted to I would just do $rowset->toArray()
  [/EDIT]</p>
  
  <p><strong>Solution</strong>: I ended up doing what I thought I wasn't able too, meaning I integrated everything into the initial query.</p>