當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Zend_Paginator::getAdapter方法代碼示例

本文整理匯總了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;
 }
開發者ID:josmel,項目名稱:adminwap,代碼行數:41,代碼來源:JqGrid.php

示例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);
         }
     }
 }
開發者ID:GemsTracker,項目名稱:MUtil,代碼行數:22,代碼來源:PagePanel.php


注:本文中的Zend_Paginator::getAdapter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。