Hi.

I have a kind of strange situation. I have a Zend\Db\ResultSet object from a
db query with 5 rows of data in it. This object is then sent to the view for
display.

When i send it to the content template (the ViewModel returned by the
controller action method), it works fine:

$model = new ViewModel();
$model->setVariable('categories', $categories);
return $model

and i can traverse the content in the view. But if i send it to a child
model that I i have initiated in the same controller method like this:

$menu = new ViewModel();
$menu->setVariable('categories', $categories);
$model->layout()->addChild($menu, 'left');

I get an exception when I try to traverse the same way in that view (the
exact same view code). The exception is this one in the rewind method of the
Result class:

throw new Exception\RuntimeException('This result is a forward only result
set, calling rewind() after moving forward is not supported');

This occurs because $this->position is set to 5, as if it has allready
traversed the results before it gets to the view. I only use the result
object one time, and the object has position set to -1 before it is sent to
$menu->setVariable but when the object is available in the view, it is
position=5. 

It looks like the variable object is traversed when sent to a child model
but not to the main view. Any idea what could cause this?

--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/ZF2-DB-Result-position-forwarded-tp4655406.html
Sent from the Zend Framework mailing list archive at Nabble.com.

-- 
List: fw-general@lists.zend.com
Info: http://framework.zend.com/archives
Unsubscribe: fw-general-unsubscr...@lists.zend.com


Reply via email to