I am not looking for $myRowset->toArray();
because I want to get an array of objects.
What I want to do is to be able to merge $myRowset
with an array of objects.
$myOtherArray = [new Foo(), new Bar()];
$array = array_merge($myRowset, $myOtherArray);
With a Zend_Db_Table_Rowset, it is impossible. Using $myRowset->toArray();
doesn't work too because I need an array of objects.
Edit - Example of code doing what I want, but I'm looking for a better solution if it exists:
// Convert the Zend_Db_Table_Rowset to an array of Zend_Db_Table_Row
$myRowset = $dbTable->fetchAll();
$rowArray = array();
foreach ($myRowset as $row) {
$rowArray[] = $row;
}
// Merge with other array of objects
$myOtherArray = [new Foo(), new Bar()];
$finalArray = array_merge($rowArray, $myOtherArray);
You can use
/** @var Zend_Db_Table_Row[] $rows */
$rows = iterator_to_array($rowset)