tec*_*l87 2 zend-framework zend-paginator
我正在使用zend paginator.我使用$ 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] =>
)
Run Code Online (Sandbox Code Playgroud)
我已经使用for循环访问了$ this-> paginator,并且每件事都运行良好.但现在我只想访问[_array:protected] => Array值,并希望使用array_slice将结果拆分为3组.但我无法访问该数组值.我尝试过将其类型转换为数组,但没有得到它.
实际上,Zend_Paginator_Adapter_Array该类有一个getItems()方法就是这样做:切割_array容器.
因此,如果您想要结果集的前三分之一,您可以执行以下操作:
$adapter = $paginator->getAdapter();
$results = $adapter->getItems(0, $adapter->count() / 3);
Run Code Online (Sandbox Code Playgroud)