Paginator with ResultSet Iterator

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Paginator with ResultSet Iterator

samsonasik
This post has NOT been accepted by the mailing list yet.
I have an resultset like this :

fetchAll()
{
    $resultSet = $this->select(function (Select $select){
            $select->columns(array('id', 'name'));
            $select->order(array('id asc'));  
    });
}

and i want to use paginator as Iterator Adapter :

       
$iteratorAdapter = new \Zend\Paginator\Adapter\Iterator($this->getSampleTable()->fetchAll());
$paginator = new \Zend\Paginator\Paginator($iteratorAdapter);

and the error is :

This result is a forward only result set, calling rewind() after moving forward is not supported

After i read the Zend\Db\Adapter\Driver\Pdo\Result, this is because $statementMode is self::STATEMENT_MODE_FORWARD in rewind() function.

How to fix this ?
Thanks in advance.

Reply | Threaded
Open this post in threaded view
|

Re: Paginator with ResultSet Iterator

samsonasik
Already fixed.
I do this :

 $resultSet = $this->select(function (Select $select){
            $select->columns(array('id', 'name'));
            $select->order(array('id asc'));  
 });

$resultSet->buffer();
       
return $resultSet;
Reply | Threaded
Open this post in threaded view
|

Re: Paginator with ResultSet Iterator

samsonasik
ooops, the right way, need next() fuction

$resultSet = $this->select(function (Select $select){ 
            $select->columns(array('id', 'name')); 
            $select->order(array('id asc'));   
 }); 

$resultSet->buffer(); 
$resultSet->next();
        
return $resultSet; 


....

Pada Sep 25, 2012, at 16:51, "samsonasik [via Zend Framework Community]"<[hidden email]> menulis:

resultSet = $this->select(function (Select $select){
            $select->columns(array('id', 'name'));
            $select->order(array('id asc'));  
 });

$resultSet->buffer();
       
return $resultSet;