I would like to iterate over the data rows stored in the Zend_Db_Table_Rowset object, and then discard / delete some of the rows if they do not meet certain criteria.
I could use toArray () to get only rows of data from the object, and then it would be easy to undo rows that I don't need. But since I want to save the object for future use, I do not want to do this.
Of course, one solution would be to tweak my query to get only what I need, but this is not possible in this scenario. At least I don’t know how.
I tried the following which did not work:
foreach ($rowset as $key => $row) { if (!$condition == satisfied) { unset($rowset[$key]); } }
And, of course, this will not work, since there is no $ rowset [$ key] ... the data is stored in the [_data: protected] subarray, but unset $ rowset [_data: protected] [$ key] does not work either.
Perhaps my concept of a rowset object (or the representation of objects in general) is not mature enough to understand what I'm doing. Any clarifications and tips would be appreciated!
[EDIT] $ row-> delete is NOT an option, I do not want to delete a row from the database! I don’t want to create an array first if I wanted to just do $ rowset-> toArray () [/ EDIT]
Solution . I ended up thinking that I also couldn’t, which means that I included everything in the original request.
source share