Zend Pagination : How ot get arrray of data

2k Views Asked by At

I am using zend paginator. I am getting following structure by using $this->paginator:



(
   [_cacheEnabled:protected] => 1
    [_adapter:protected] => Zend_Paginator_Adapter_Array Object
        (
            [_array:protected] => Array
                (
                    [0] => Array
                        (
                        )
                    [1] => Array
                         (
                         )
                           )

            [_count:protected] => 8
        )

    [_currentItemCount:protected] => 
    [_currentItems:protected] => 
    [_currentPageNumber:protected] => 1
    [_filter:protected] => 
    [_itemCountPerPage:protected] => 4
    [_pageCount:protected] => 2
    [_pageRange:protected] => 
    [_pages:protected] => 
    [_view:protected] => 
)


I have accessed $this->paginator using for loop and every thing is working fine. but now I want to access only [_array:protected] => Array value and want to split the result in 3 sets using array_slice. But I am not able to access that array values. I have tried by type casting it to array but not getting it.

1

There are 1 best solutions below

1
On BEST ANSWER

Actually, the Zend_Paginator_Adapter_Array class has a getItems() method which does exactly that : slice the _array container.

So if you want the first third of the result set you can do :

$adapter = $paginator->getAdapter();
$results = $adapter->getItems(0, $adapter->count() / 3);