Mam questa...
Na wstępie kod:
W MODELU
public function fetchAll() { $resultSet = $this->tableGateway->select(); return $resultSet; }
W KONTROLERZE
public function indexAction() { $userTable = $this->getServiceLocator()->get('UserTable'); return $viewModel; }
W WIDOKU
REZULTAT VAR_DUMPA
object(Zend\Db\ResultSet\ResultSet)#263 (8) { ["allowedReturnTypes":protected]=> [0]=> string(11) "arrayobject" [1]=> string(5) "array" } ["arrayObjectPrototype":protected]=> object(Users\Model\User)#247 (4) { ["id"]=> NULL ["name"]=> NULL ["email"]=> NULL ["password"]=> NULL } ["returnType":protected]=> string(11) "arrayobject" ["buffer":protected]=> NULL ["count":protected]=> int(3) ["dataSource":protected]=> object(Zend\Db\Adapter\Driver\Pdo\Result)#262 (8) { ["statementMode":protected]=> string(7) "forward" ["resource":protected]=> object(PDOStatement)#253 (1) { ["queryString"]=> string(27) "SELECT `user`.* FROM `user`" } ["options":protected]=> NULL ["currentComplete":protected]=> bool(false) ["currentData":protected]=> NULL ["position":protected]=> int(-1) ["generatedValue":protected]=> string(1) "0" ["rowCount":protected]=> int(3) } ["fieldCount":protected]=> int(4) ["position":protected]=> int(0) }
I teraz pytanie

Jak zrobić, żebym w widoku mógł posłigiwać się zwykłą tablicą? $resultSet zwraca obiekt typu ResultSet. Kiedy robię ->toArray(), rzutuję na array lub próbuję normalnego foreacha to zwraca błąd: Rows as part of this DataSource, with type object cannot be cast to an array.