本文整理汇总了PHP中Zend_Paginator::getCurrentItems方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Paginator::getCurrentItems方法的具体用法?PHP Zend_Paginator::getCurrentItems怎么用?PHP Zend_Paginator::getCurrentItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Paginator
的用法示例。
在下文中一共展示了Zend_Paginator::getCurrentItems方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCurrentItems
/**
* Get current items to display on current page
* @access public
* @return object ArrayIterator
*/
public function getCurrentItems()
{
$this->_paginator->setItemCountPerPage($this->_itemCountPerPage);
$this->_paginator->setCurrentPageNumber($this->_currentPage);
if ($this->_currentItems === null) {
$this->_currentItems = $this->_paginator->getCurrentItems();
}
return $this->_currentItems;
}
示例2: fetchByType
public static function fetchByType($type = 1, $page = 1, $perpage = 30)
{
if ($type != 0 && $type != 1 && $type != 2) {
return array();
}
$select = self::select();
if ($type != 0) {
$select->where('type = ?', $type);
}
$select->order('sort asc');
$adapter = new Zend_Paginator_Adapter_DbTableSelect($select);
$paginator = new Zend_Paginator($adapter);
$paginator->setItemCountPerPage($perpage)->setCurrentPageNumber($page);
$data = $paginator->getCurrentItems();
$pages = $paginator->count();
$destinations = array();
if (count($data) > 0) {
foreach ($data as $da) {
$destinationModel = new Application_Model_O_Destination();
$destinationModel->setId($da->id)->setCity($da->city)->setType($da->type)->setLongitude($da->longitude)->setLatitude($da->latitude)->setImg($da->img)->setSort($da->sort)->setCtime($da->ctime)->setUtime($da->utime)->setStatus($da->status);
array_push($destinations, $destinationModel);
}
}
$res = array('destinations' => $destinations, 'pages' => $pages);
return $res;
}
示例3: fetchByType
public static function fetchByType($type = 1, $filter, $order, $page = 1)
{
if ($type != 1 && $type != 2 && $type != 3) {
return array();
}
$select = self::select();
$select->where('type = ?', $type)->where('status =1');
if ($filter == 1 || $filter == 2) {
$select->where('location_type = ?', $filter);
}
if ($order == 1) {
$select->order('adult_dprice desc');
} elseif ($order == 2) {
$select->order('adult_dprice asc');
} elseif ($order == 3) {
$select->order('sales desc');
} elseif ($order == 4) {
$select->order('sales asc');
}
$adapter = new Zend_Paginator_Adapter_DbTableSelect($select);
$paginator = new Zend_Paginator($adapter);
$paginator->setItemCountPerPage(10)->setCurrentPageNumber($page);
$data = $paginator->getCurrentItems();
$pages = $paginator->count();
$travels = array();
if (count($data) > 0) {
foreach ($data as $da) {
$travelModel = new Application_Model_O_Travel();
$travelModel->setId($da->id)->setType($da->type)->setLocation_type($da->location_type)->setAdult_oprice($da->adult_oprice)->setAdult_dprice($da->adult_dprice)->setChild_oprice($da->child_oprice)->setChild_dprice($da->child_dprice)->setArea($da->area)->setSales($da->sales)->setTitle($da->title)->setSubtitle($da->subtitle)->setImg($da->img)->setCtime($da->ctime)->setUtime($da->utime)->setStatus($da->status);
array_push($travels, $travelModel);
}
}
$res = array('travels' => $travels, 'pages' => $pages);
return $res;
}
示例4: fetchAllPage
public static function fetchAllPage($role, $page = 1, $perpage = 30)
{
if ($role != 0 && $role != 1 && $role != 2 && $role != 3) {
return array();
}
$select = self::select();
if ($role != 0) {
$select->where('urole = ?', $role)->order('ctime desc');
}
$adapter = new Zend_Paginator_Adapter_DbTableSelect($select);
$paginator = new Zend_Paginator($adapter);
$paginator->setItemCountPerPage($perpage)->setCurrentPageNumber($page);
$data = $paginator->getCurrentItems();
$pages = $paginator->count();
$orders = array();
if (count($data) > 0) {
foreach ($data as $da) {
$orderModel = new Application_Model_O_MemberCardOrder();
$orderModel->setId($da->id)->setOrder_id($da->order_id)->setUid($da->uid)->setUrole($da->urole)->setMember_card_id($da->member_card_id)->setTotal_price($da->total_price)->setPayment_status($da->payment_status)->setRemark($da->remark)->setCtime($da->ctime)->setUtime($da->utime)->setStatus($da->status);
array_push($orders, $orderModel);
}
}
$res = array('orders' => $orders, 'pages' => $pages);
return $res;
}
示例5: fetchByDepartmentHospital
public static function fetchByDepartmentHospital($department, $hospital, $sort, $page)
{
$select = self::select();
if ($department) {
$select->where("department like '%{$department}%'")->orWhere("special like '%{$department}%'");
}
if ($hospital) {
$select->where('hospital = ?', $hospital);
}
if ($sort == 1) {
//asc
$select->order('reservation_number asc');
} elseif ($sort == 2) {
//desc
$select->order('reservation_number desc');
}
$select->where('status = 1');
$adapter = new Zend_Paginator_Adapter_DbTableSelect($select);
$paginator = new Zend_Paginator($adapter);
$paginator->setItemCountPerPage(10)->setCurrentPageNumber($page);
$data = $paginator->getCurrentItems();
$pages = $paginator->count();
$doctors = array();
if (count($data) > 0) {
foreach ($data as $da) {
$doctorModel = new Application_Model_O_Doctor();
$doctorModel->setId($da->id)->setName($da->name)->setAvatar($da->avatar)->setSex($da->sex)->setBirthday($da->birthday)->setEmail($da->email)->setPasswd($da->passwd)->setPhone($da->phone)->setDepartment($da->department)->setPoint($da->point)->setCity($da->city)->setCertified($da->certified)->setSpecial($da->special)->setCountry($da->country)->setIntroduction($da->introduction)->setHospital($da->hospital)->setArea($da->area)->setQualification($da->qualification)->setReservation_fee($da->reservation_fee)->setReservation_number($da->reservation_number)->setCtime($da->ctime)->setUtime($da->utime)->setStatus($da->status);
array_push($doctors, $doctorModel);
}
}
$res = array('doctors' => $doctors, 'pages' => $pages);
return $res;
}
示例6: testPaginator
public function testPaginator()
{
$countries = My_ShantyMongo_Country::all();
$this->assertEquals(239, $countries->count());
$paginator = new Zend_Paginator(new Shanty_Paginator_Adapter_Mongo($countries));
$paginator->setItemCountPerPage(10);
$paginator->setCurrentPageNumber(3);
$this->assertEquals(24, $paginator->count());
// Count pages
$this->assertEquals(239, $paginator->getTotalItemCount());
// count total items
$this->assertEquals(10, $paginator->getCurrentItemCount());
// count items on this page
$paginator->getCurrentItems()->rewind();
$firstItem = $paginator->getCurrentItems()->current();
$this->assertEquals($firstItem->code, 'BB');
$this->assertEquals($firstItem->name, 'Barbados');
}
示例7: testWithCacheDisabled
public function testWithCacheDisabled()
{
$this->_paginator->setCacheEnabled(false);
$this->_paginator->setCurrentPageNumber(1)->getCurrentItems();
$cachedPageItems = $this->_paginator->getPageItemCache();
$expected = new \ArrayIterator(range(1, 10));
$this->assertEquals(array(), $cachedPageItems);
$pageItems = $this->_paginator->getCurrentItems();
$this->assertEquals($expected, $pageItems);
}
示例8: testGetCurrentItems
public function testGetCurrentItems()
{
$this->_restorePaginatorDefaults();
$items = $this->_paginator->getCurrentItems();
$this->assertType('ArrayIterator', $items);
$count = 0;
foreach ($items as $item) {
$count++;
}
$this->assertEquals(10, $count);
}
示例9: search
/**
* Returns a paginated list of all sites matching the given parameters.
*
* @param array $params
* @return array
*/
public static function search(array $params)
{
$siteDb = Yadda_Db_Table::getInstance('site');
$select = $siteDb->select()->setIntegrityCheck(false)->from('site')->joinLeft('deal', 'site.id = deal.site_id', array('latest_deal' => 'MAX(deal.created)'))->where('site.status = ?', 'active')->group('site.id')->order('site.name');
// fetch
$paginator = new Zend_Paginator(new Zend_Paginator_Adapter_DbSelect($select));
$paginator->setCurrentPageNumber(isset($params['page']) ? (int) $params['page'] : 1);
$paginator->setItemCountPerPage(isset($params['count']) ? (int) $params['count'] : 10);
$return = array('params' => $params, 'total' => $paginator->getTotalItemCount(), 'page' => $paginator->getCurrentPageNumber(), 'pages' => $paginator->count(), 'results' => array());
$sites = new Zend_Db_Table_Rowset(array('table' => $siteDb, 'data' => (array) $paginator->getCurrentItems()));
foreach ($sites as $site) {
$return['results'][] = self::toArray($site);
}
return $return;
}
示例10: search
public static function search($params)
{
// build query
$subscriptionDb = Yadda_Db_Table::getInstance('subscription');
$select = $subscriptionDb->select()->setIntegrityCheck(false)->from('subscription')->joinLeft('user', 'subscription.user_id = user.id', array('user_email' => 'email'))->where('subscription.status = ?', 'active')->order('created DESC');
// fetch
$paginator = new Zend_Paginator(new Zend_Paginator_Adapter_DbSelect($select));
$paginator->setCurrentPageNumber(isset($params['page']) ? (int) $params['page'] : 1);
$paginator->setItemCountPerPage(isset($params['count']) ? (int) $params['count'] : 10);
$return = array('params' => $params, 'total' => $paginator->getTotalItemCount(), 'page' => $paginator->getCurrentPageNumber(), 'pages' => $paginator->count(), 'results' => array());
$subscriptions = new Zend_Db_Table_Rowset(array('table' => $subscriptionDb, 'data' => (array) $paginator->getCurrentItems()));
foreach ($subscriptions as $subscription) {
$return['results'][] = self::toArray($subscription);
}
return $return;
}
示例11: search
/**
* Returns a paginated list of regions matching the given parameters.
*
* @param array $params
* @return array
*/
public static function search(array $params)
{
// build query
$regionDb = Yadda_Db_Table::getInstance('region');
$select = $regionDb->select()->from('region')->where('status = ?', 'active')->order('name');
// fetch
$paginator = new Zend_Paginator(new Zend_Paginator_Adapter_DbSelect($select));
$paginator->setCurrentPageNumber(isset($params['page']) ? (int) $params['page'] : 1);
$paginator->setItemCountPerPage(isset($params['count']) ? (int) $params['count'] : 10);
$return = array('params' => $params, 'total' => $paginator->getTotalItemCount(), 'page' => $paginator->getCurrentPageNumber(), 'pages' => $paginator->count(), 'results' => array());
$regions = new Zend_Db_Table_Rowset(array('table' => $regionDb, 'data' => (array) $paginator->getCurrentItems()));
foreach ($regions as $region) {
$return['results'][] = self::toArray($region);
}
return $return;
}
示例12: fetchAllPage
public static function fetchAllPage($page = 1, $perpage = 30)
{
$select = self::select();
$adapter = new Zend_Paginator_Adapter_DbTableSelect($select);
$paginator = new Zend_Paginator($adapter);
$paginator->setItemCountPerPage($perpage)->setCurrentPageNumber($page);
$data = $paginator->getCurrentItems();
$pages = $paginator->count();
$cards = array();
if (count($data) > 0) {
foreach ($data as $da) {
$cardModel = new Application_Model_O_MemberCard();
$cardModel->setId($da->id)->setName($da->name)->setOprice($da->oprice)->setDprice($da->dprice)->setPoints($da->points)->setCtime($da->ctime)->setUtime($da->utime)->setStatus($da->status);
array_push($cards, $cardModel);
}
}
$res = array('cards' => $cards, 'pages' => $pages);
return $res;
}
示例13: fetchAllPage
public static function fetchAllPage($page = 1, $perpage = 30)
{
$select = self::select();
$adapter = new Zend_Paginator_Adapter_DbTableSelect($select);
$paginator = new Zend_Paginator($adapter);
$paginator->setItemCountPerPage($perpage)->setCurrentPageNumber($page);
$data = $paginator->getCurrentItems();
$pages = $paginator->count();
$feedbacks = array();
if (count($data) > 0) {
foreach ($data as $da) {
$feedbackModel = new Application_Model_O_Feedback();
$feedbackModel->setId($da->id)->setContent($da->content)->setContact($da->contact)->setCtime($da->ctime)->setUtime($da->utime)->setStatus($da->status);
array_push($feedbacks, $feedbackModel);
}
}
$res = array('feedbacks' => $feedbacks, 'pages' => $pages);
return $res;
}
示例14: fetchAllPage
public static function fetchAllPage($page = 1, $perpage = 30)
{
$select = self::select();
$adapter = new Zend_Paginator_Adapter_DbTableSelect($select);
$paginator = new Zend_Paginator($adapter);
$paginator->setItemCountPerPage($perpage)->setCurrentPageNumber($page);
$data = $paginator->getCurrentItems();
$pages = $paginator->count();
$applys = array();
if (count($data) > 0) {
foreach ($data as $da) {
$applyModel = new Application_Model_O_GlobalConsultationApply();
$applyModel->setId($da->id)->setDepartment_category_id($da->department_category_id)->setDepartment_id($da->department_id)->setEmail($da->email)->setMobile($da->mobile)->setAge($da->age)->setSex($da->sex)->setLocation($da->location)->setTreatment_time($da->treatment_time)->setOpinion($da->opinion)->setReport($da->report)->setCtime($da->ctime)->setUtime($da->utime)->setStatus($da->status);
array_push($applys, $applyModel);
}
}
$res = array('applys' => $applys, 'pages' => $pages);
return $res;
}
示例15: fetchAllPage
public static function fetchAllPage($type = 1, $page = 1, $perpage = 30)
{
$select = self::select();
$select->where('type = ?', $type)->order('sort asc');
$adapter = new Zend_Paginator_Adapter_DbTableSelect($select);
$paginator = new Zend_Paginator($adapter);
$paginator->setItemCountPerPage($perpage)->setCurrentPageNumber($page);
$data = $paginator->getCurrentItems();
$pages = $paginator->count();
$articles = array();
if (count($data) > 0) {
foreach ($data as $da) {
$articleModel = new Application_Model_O_Article();
$articleModel->setId($da->id)->setTitle($da->title)->setContent($da->content)->setImg($da->img)->setSort($da->sort)->setType($da->type)->setCtime($da->ctime)->setUtime($da->utime)->setStatus($da->status);
array_push($articles, $articleModel);
}
}
$res = array('articles' => $articles, 'pages' => $pages);
return $res;
}