当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Paginator::clearPageItemCache方法代码示例

本文整理汇总了PHP中Zend_Paginator::clearPageItemCache方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Paginator::clearPageItemCache方法的具体用法?PHP Zend_Paginator::clearPageItemCache怎么用?PHP Zend_Paginator::clearPageItemCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Paginator的用法示例。


在下文中一共展示了Zend_Paginator::clearPageItemCache方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testClearPageItemCache

 public function testClearPageItemCache()
 {
     $this->_paginator->setCurrentPageNumber(1)->getCurrentItems();
     $this->_paginator->setCurrentPageNumber(2)->getCurrentItems();
     $this->_paginator->setCurrentPageNumber(3)->getCurrentItems();
     // clear only page 2 items
     $this->_paginator->clearPageItemCache(2);
     $pageItems = $this->_paginator->getPageItemCache();
     $expected = array(1 => new \ArrayIterator(range(1, 10)), 3 => new \ArrayIterator(range(21, 30)));
     $this->assertEquals($expected, $pageItems);
     // clear all
     $this->_paginator->clearPageItemCache();
     $pageItems = $this->_paginator->getPageItemCache();
     $this->assertEquals(array(), $pageItems);
 }
开发者ID:rafalwrzeszcz,项目名称:zf2,代码行数:15,代码来源:PaginatorTest.php

示例2: GetPaginatorPosts

 /**
  * Get the array of records satisfying the criteria specified in the parameter $options using Zend_Paginator
  * 
  * @param Zend_Db_Adapter_Abstract $db
  * @param array $options
  * @return array  Default_Model_DbTable_BlogPost objects
  */
 public static function GetPaginatorPosts($db, $options = array())
 {
     $arrResult = array();
     $_config = Zend_Registry::get('config');
     $itemCountPerPage = (int) $_config['paginator']['itemCountPerPage'];
     $pagesInRange = (int) $_config['paginator']['pagesInRange'];
     //---------------------------------------------------------
     // инициализация опций
     $defaults = array('itemCountPerPage' => $itemCountPerPage, 'pagesInRange' => $pagesInRange, 'page' => 1, 'offset' => 0, 'limit' => 0, 'order' => 'p.ts_created', 'sort' => true);
     foreach ($defaults as $k => $v) {
         $options[$k] = array_key_exists($k, $options) ? $options[$k] : $v;
     }
     $select = self::_GetBaseQuery($db, $options);
     // установим поля таблицы для запроса
     $select->from(null, 'p.*');
     // set the offset, limit, and ordering of results
     if ($options['limit'] > 0) {
         $select->limit($options['limit'], $options['offset']);
     }
     // Установим параметры сортировки для таблицы
     if ($options['sort']) {
         $select = self::GetSelectForSort($select, $options);
     }
     //------ Создадим обьект Zend_Paginator ---------
     $strSelect = $select->__toString();
     $adapter = new Zend_Paginator_Adapter_DbSelect($select);
     $count = self::GetPostsCount($db, $options);
     $adapter->setRowCount($count);
     $paginator = new Zend_Paginator($adapter);
     // Установим максимальное количество отображаемых на странице элементов
     $paginator->setItemCountPerPage($options['itemCountPerPage']);
     // Установи массив страниц, возвращенный текущим стилем прокрутки
     $paginator->setPageRange($options['pagesInRange']);
     // Установим текущую страницу
     $paginator->setCurrentPageNumber($options['page']);
     //----- Конфигурирование кеша для Paginator -----
     $pgCache = Default_Plugin_SysBox::getCache('paginator');
     if ($pgCache->getOption('caching')) {
         // Установим кеш для Paginator
         Zend_Paginator::setCache($pgCache);
         // Очищение кеша
         if (Default_Plugin_SysBox::isCleanCache()) {
             $paginator->clearPageItemCache();
         }
     }
     // получим данные в виде массива обьектов Default_Model_DbTable_BlogPost
     $posts = self::BuildMultiple($db, __CLASS__, $paginator);
     $post_ids = array_keys($posts);
     if (count($post_ids) == 0) {
         return array();
     }
     // получим данные о загруженных сообщениях
     $profiles = Default_Model_Profile::BuildMultiple($db, 'Default_Model_DbTable_BlogPostProfile', array($post_ids));
     foreach ($posts as $post_id => $post) {
         if (array_key_exists($post_id, $profiles) && $profiles[$post_id] instanceof Default_Model_DbTable_BlogPostProfile) {
             $posts[$post_id]->profile = $profiles[$post_id];
         } else {
             $posts[$post_id]->profile->setPostId($post_id);
         }
         //!!!!------ Начало установки признака сортировки -----!!!!!
         if (isset($options['sortColumn'])) {
             $posts[$post_id]->sortColumn = $options['sortColumn'];
         }
         if (isset($options['ascDescFlg'])) {
             $posts[$post_id]->ascDescFlg = $options['ascDescFlg'];
         }
         //!!!!------ Конец установки признака сортировки -----!!!!!
     }
     // load the images for each post
     $options = array('post_id' => $post_ids);
     $images = Default_Model_DbTable_BlogPostImage::GetImages($db, $options);
     foreach ($images as $image) {
         $posts[$image->post_id]->images[$image->getId()] = $image;
     }
     // load the locations for each post
     $locations = Default_Model_DbTable_BlogPostLocation::GetLocations($db, $options);
     foreach ($locations as $l) {
         $posts[$l->post_id]->locations[$l->getId()] = $l;
     }
     // load the audio for each post
     $audios = Default_Model_DbTable_BlogPostAudio::GetAudio($db, $options);
     foreach ($audios as $audio) {
         $posts[$audio->post_id]->audio[$audio->getId()] = $audio;
     }
     // load the video for each post
     $videos = Default_Model_DbTable_BlogPostVideo::GetVideo($db, $options);
     foreach ($videos as $video) {
         $posts[$video->post_id]->video[$video->getId()] = $video;
     }
     // load the comments for each post
     $comments = Default_Model_DbTable_BlogPostComment::GetComments($db, $options);
     foreach ($comments as $comment) {
         $posts[$comment->post_id]->comments[$comment->getId()] = $comment;
//.........这里部分代码省略.........
开发者ID:bsa-git,项目名称:zf-myblog,代码行数:101,代码来源:BlogPost.php


注:本文中的Zend_Paginator::clearPageItemCache方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。