本文整理汇总了PHP中Zend_Paginator::getAdapter方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Paginator::getAdapter方法的具体用法?PHP Zend_Paginator::getAdapter怎么用?PHP Zend_Paginator::getAdapter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Paginator
的用法示例。
在下文中一共展示了Zend_Paginator::getAdapter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _createGridData
/**
* Create the grid data structure
*
* @return object
*/
protected function _createGridData(Zend_Controller_Request_Abstract $request)
{
// Instantiate Zend_Paginator with the required data source adaptor
if (!$this->_paginator instanceof Zend_Paginator) {
$this->_paginator = new Zend_Paginator($this->_adapter);
$this->_paginator->setDefaultItemCountPerPage($request->getParam('rows', $this->_defaultItemCountPerPage));
}
// Filter items by supplied search criteria
if ($request->getParam('_search') == 'true') {
$filter = $this->_getFilterParams($request);
$this->_paginator->getAdapter()->filter($filter['field'], $filter['value'], $filter['expression'], $filter['options']);
}
// Sort items by the supplied column field
if ($request->getParam('sidx')) {
$this->_paginator->getAdapter()->sort($request->getParam('sidx'), $request->getParam('sord', 'asc'));
}
// Pass the current page number to paginator
$this->_paginator->setCurrentPageNumber($request->getParam('page', 1));
// Fetch a row of items from the adapter
$rows = $this->_paginator->getCurrentItems();
$grid = new stdClass();
$grid->page = $this->_paginator->getCurrentPageNumber();
$grid->total = $this->_paginator->getItemCountPerPage();
$grid->records = $this->_paginator->getTotalItemCount();
$grid->rows = array();
foreach ($rows as $k => $row) {
if (isset($row['id'])) {
$grid->rows[$k]['id'] = $row['id'];
}
$grid->rows[$k]['cell'] = array();
foreach ($this->_columns as $column) {
array_push($grid->rows[$k]['cell'], $column->cellValue($row));
}
}
return $grid;
}
示例2: _checkVariables
protected function _checkVariables($force = false)
{
if ($this->_paginator) {
if ($force || $this->_currentPage || $this->_request) {
$this->_paginator->setCurrentPageNumber($this->getCurrentPage());
}
if ($force || $this->_itemCount || $this->_request) {
if (!$this->_itemCount) {
$this->getItemCount();
}
// Recently found trick, can save a complicated database query
// Fetch the items first and get the count in the same query
$adapter = $this->_paginator->getAdapter();
if ($adapter instanceof \MUtil_Paginator_Adapter_PrefetchInterface) {
$offset = ($this->_currentPage - 1) * $this->_itemCount;
// Calculate correct offset
$adapter->getItems($offset, $this->_itemCount);
}
$this->_paginator->setItemCountPerPage($this->_itemCount);
}
}
}