国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Table of Contents
Detailed explanation of the usage of Zend Framework paging class, zendframework
Articles you may be interested in:
Home Backend Development PHP Tutorial Detailed explanation of the usage of Zend Framework paging class, zendframework_PHP tutorial

Detailed explanation of the usage of Zend Framework paging class, zendframework_PHP tutorial

Jul 12, 2016 am 08:56 AM
framework zend

Detailed explanation of the usage of Zend Framework paging class, zendframework

The examples in this article describe the usage of Zend Framework paging class. Share it with everyone for your reference, the details are as follows:

1. Pagination class Pagination.php, it is best to put this class in the Zend directory

class XY_Pagination
{
  private $_navigationItemCount = 10; //導(dǎo)航欄顯示導(dǎo)航總頁數(shù)
  private $_pageSize = null; //每頁項(xiàng)目數(shù)
  private $_align = "right"; //導(dǎo)航欄顯示位置
  private $_itemCount = null; //總項(xiàng)目數(shù)
  private $_pageCount = null; //總頁數(shù)
  private $_currentPage = null; //當(dāng)前頁
  private $_front = null; //前端控制器
  private $_PageParaName = "page"; //頁面參數(shù)名稱
  private $_firstPageString = "|<<"; //導(dǎo)航欄中第一頁顯示的字符
  private $_nextPageString = ">>"; //導(dǎo)航欄中前一頁顯示的字符
  private $_previousPageString = "<<"; //導(dǎo)航欄中后一頁顯示的字符
  private $_lastPageString = ">>|"; //導(dǎo)航欄中最后一頁顯示的字符
  private $_splitString = " | ";
         //頁數(shù)字間的間隔符 /
  public function __construct($itemCount, $pageSize)
  {
    if(!is_numeric($itemCount) || (!is_numeric($pageSize)))
    throw new Exception("Pagination Error:not Number");
    $this->_itemCount = $itemCount;
    $this->_pageSize = $pageSize;
    $this->_front = Zend_Controller_Front::getInstance();
    $this->_pageCount = ceil($itemCount/$pageSize); //總頁數(shù)
    $page = $this->_front->getRequest()->getParam($this->_PageParaName);
    if(empty($page) || (!is_numeric($page))) //為空或不是數(shù)字,設(shè)置當(dāng)前頁為1
    {
      $this->_currentPage = 1;
    }
    else
    {
      if($page < 1)
        $page = 1;
      if($page > $this->_pageCount)
        $page = $this->_pageCount;
      $this->_currentPage = $page;
    }
  }
  /**
   * 返回當(dāng)前頁
   * @param int 當(dāng)前頁
   */
  public function getCurrentPage()
  {
    return $this->_currentPage;
  }
  /**
   * 返回導(dǎo)航欄目
   * @return string 導(dǎo)航html class="PageNavigation"
   */
  public function getNavigation()
  {
    $navigation = '';
    $pageCote = ceil($this->_currentPage / ($this->_navigationItemCount - 1)) - 1; //當(dāng)前頁處于第幾欄分頁
    $pageCoteCount = ceil($this->_pageCount / ($this->_navigationItemCount - 1)); //總分頁欄
    $pageStart = $pageCote * ($this->_navigationItemCount -1) + 1; //分頁欄中起始頁
    $pageEnd = $pageStart + $this->_navigationItemCount - 1; //分頁欄中終止頁
    if($this->_pageCount < $pageEnd)
    {
      $pageEnd = $this->_pageCount;
    }
        $navigation .= "總共:{$this->_itemCount}條 {$this->_pageCount}頁\n";
    if($pageCote > 0) //首頁導(dǎo)航
    {
      $navigation .= '$this->_firstPageString ";
    }
    if($this->_currentPage != 1) //上一頁導(dǎo)航
    {
      $navigation .= '$this->_previousPageString ";
    }
    while ($pageStart <= $pageEnd) //構(gòu)造數(shù)字導(dǎo)航區(qū)
    {
      if($pageStart == $this->_currentPage)
      {
        $navigation .= "$pageStart".$this->_splitString;
      }
      else
      {
        $navigation .= '$pageStart".$this->_splitString;
      }
      $pageStart++;
    }
    if($this->_currentPage != $this->_pageCount) //下一頁導(dǎo)航
    {
      $navigation .= ' $this->_nextPageString ";
    }
    if($pageCote < $pageCoteCount-1) //未頁導(dǎo)航
    {
      $navigation .= '$this->_lastPageString ";
    }
    //添加直接導(dǎo)航框
    //$navigation .= '';
    //2008年8月27號補(bǔ)充輸入非正確頁碼后出現(xiàn)的錯(cuò)誤——begin
    $navigation .= ' ';
    //2008年8月27號補(bǔ)充輸入非正確頁碼后出現(xiàn)的錯(cuò)誤——end
    $navigation .= " ";
    return $navigation;
  }
  /**
   * 取得導(dǎo)航欄顯示導(dǎo)航總頁數(shù)
   *
   * @return int 導(dǎo)航欄顯示導(dǎo)航總頁數(shù)
   */
  public function getNavigationItemCount()
  {
    return $this->_navigationItemCount;
  }
  /**
   * 設(shè)置導(dǎo)航欄顯示導(dǎo)航總頁數(shù)
   *
   * @param int $navigationCount:導(dǎo)航欄顯示導(dǎo)航總頁數(shù)
   */
  public function setNavigationItemCoun($navigationCount)
  {
    if(is_numeric($navigationCount))
    {
      $this->_navigationItemCount = $navigationCount;
    }
  }
  /**
   * 設(shè)置首頁顯示字符
   * @param string $firstPageString 首頁顯示字符
   */
  public function setFirstPageString($firstPageString)
  {
    $this->_firstPageString = $firstPageString;
  }
  /**
   * 設(shè)置上一頁導(dǎo)航顯示字符
   * @param string $previousPageString:上一頁顯示字符
   */
  public function setPreviousPageString($previousPageString)
  {
    $this->_previousPageString = $previousPageString;
  }
  /**
   * 設(shè)置下一頁導(dǎo)航顯示字符
   * @param string $nextPageString:下一頁顯示字符
   */
  public function setNextPageString($nextPageString)
  {
    $this->_nextPageString = $nextPageString;
  }
  /**
   * 設(shè)置未頁導(dǎo)航顯示字符
   * @param string $nextPageString:未頁顯示字符
   */
  public function setLastPageString($lastPageString)
  {
    $this->_lastPageString = $lastPageString;
  }
  /**
   * 設(shè)置導(dǎo)航字符顯示位置
   * @param string $align:導(dǎo)航位置
   */
  public function setAlign($align)
  {
    $align = strtolower($align);
    if($align == "center")
    {
      $this->_align = "center";
    }elseif($align == "right")
    {
      $this->_align = "right";
    }else
    {
      $this->_align = "left";
    }
  }
  /**
   * 設(shè)置頁面參數(shù)名稱
   * @param string $pageParamName:頁面參數(shù)名稱
   */
  public function setPageParamName($pageParamName)
  {
    $this->_PageParaName = $pageParamName;
  }
  /**
   * 獲取頁面參數(shù)名稱
   * @return string 頁面參數(shù)名稱
   */
  public function getPageParamName()
  {
    return $this->_PageParaName;
  }
  /**
   * 生成導(dǎo)航鏈接地址
   * @param int $targetPage:導(dǎo)航頁
   * @return string 鏈接目標(biāo)地址
   */
  private function createHref($targetPage = null)
  {
    $params = $this->_front->getRequest()->getParams();
        $module = $params["module"];
    $controller = $params["controller"];
    $action = $params["action"];
    $targetUrl = $this->_front->getBaseUrl()."/$module/$controller/$action";
    foreach ($params as $key => $value)
    {
      if($key != "controller" && $key != "module" && $key != "action" && $key != $this->_PageParaName)
      {
        $targetUrl .= "/$key/$value";
      }
    }
    if(isset($targetPage)) //指定目標(biāo)頁
      $targetUrl .= "/$this->_PageParaName/$targetPage";
    else
      $targetUrl .= "/$this->_PageParaName/";
    return $targetUrl;
  }
}
&#63;>

2. Call in indexController Function in indexController.php:

require_once 'Zend/Pagination.php';
$Users = new Users();
//$rows = $Users->getAdapter()->fetchOne("select count(*) from users where `role`!='admin'"); //recorde count
$rows = $Users->fetchAll("`role`!='admin'")->count(); //查詢記錄總數(shù)
$rowsPerPage = 5; //perPage recordes
$curPage = 1;
if($this->_request->getParam('page'))
{
    $curPage = $this->_request->getParam('page');
}
//search data and display
$this->view->users = $Users->fetchAll("`role`!='admin'",'id desc',$rowsPerPage,($curPage-1)*$rowsPerPage)->toArray();
$Pager = new XY_Pagination($rows,$rowsPerPage);
$this->view->pagebar = $Pager->getNavigation();

3. It is easier to call paging in the view.

pagebar?>

or in case of smarty template

<{$pagebar}>

Readers who are interested in more zend-related content can check out the special topics of this site: "Zend FrameWork Framework Introductory Tutorial", "php Excellent Development Framework Summary", "Yii Framework Introduction and Summary of Common Techniques", "ThinkPHP Introductory Tutorial" , "php object-oriented programming introductory tutorial", "php mysql database operation introductory tutorial" and "php common database operation skills summary"

I hope this article will be helpful to everyone’s PHP programming based on the Zend Framework framework.

Articles you may be interested in:

  • Zend Framework Tutorial - Zend_Db_Table_Rowset Usage Example Analysis
  • Zend Framework Tutorial - Zend_Db_Table_Row Usage Example Analysis
  • Zend Framework Tutorial: Detailed explanation of Zend_Db_Table usage
  • Zend Framework tutorial: Zend_Form component to implement form submission and display error prompts
  • Zend Framework development introduction classic tutorial
  • Zend Framework Smarty extension implementation Method
  • Zend Framework routing mechanism code analysis
  • Zend Framework implements a guestbook with basic functions (with demo source code download)
  • Zend Framework implements session storage in memcache Method
  • Zend Framework implements multi-file upload function example
  • Environment configuration for getting started with Zend Framework and the first Hello World example (with demo source code download)
  • Zend Framework Tutorial How to connect to the database and perform add/delete queries (with demo source code download)
  • Detailed explanation of the Zend_Db_Table table association example in the Zend Framework tutorial

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1113724.htmlTechArticleDetailed explanation of the usage of Zend Framework paging class, zendframework This article describes the usage of Zend Framework paging class with examples. Share it with everyone for your reference, the details are as follows: 1. Pagination.ph...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to identify Windows upgrade issues using SetupDiag on Windows 11/10 How to identify Windows upgrade issues using SetupDiag on Windows 11/10 Apr 17, 2023 am 10:07 AM

Whenever your Windows 11 or Windows 10 PC has an upgrade or update issue, you will usually see an error code indicating the actual reason behind the failure. However, sometimes confusion can arise when an upgrade or update fails without an error code being displayed. With handy error codes, you know exactly where the problem is so you can try to fix it. But since no error code appears, it becomes challenging to identify the issue and resolve it. This will take up a lot of your time to simply find out the reason behind the error. In this case, you can try using a dedicated tool called SetupDiag provided by Microsoft that helps you easily identify the real reason behind the error.

Microsoft NET Framework Installation Issues Error Code 0x800c0006 Fix Microsoft NET Framework Installation Issues Error Code 0x800c0006 Fix May 05, 2023 pm 04:01 PM

.NET Framework 4 is required by developers and end users to run the latest versions of applications on Windows. However, while downloading and installing .NET Framework 4, many users complained that the installer stopped midway, displaying the following error message - " .NET Framework 4 has not been installed because Download failed with error code 0x800c0006 ". If you are also experiencing it while installing .NETFramework4 on your device then you are at the right place

SCNotification has stopped working [5 steps to fix it] SCNotification has stopped working [5 steps to fix it] May 17, 2023 pm 09:35 PM

As a Windows user, you are likely to encounter SCNotification has stopped working error every time you start your computer. SCNotification.exe is a Microsoft system notification file that crashes every time you start your PC due to permission errors and network failures. This error is also known by its problematic event name. So you might not see this as SCNotification having stopped working, but as bug clr20r3. In this article, we will explore all the steps you need to take to fix SCNotification has stopped working so that it doesn’t bother you again. What is SCNotification.e

Microsoft .NET Framework 4.5.2, 4.6, and 4.6.1 will end support in April 2022 Microsoft .NET Framework 4.5.2, 4.6, and 4.6.1 will end support in April 2022 Apr 17, 2023 pm 02:25 PM

Microsoft Windows users who have installed Microsoft.NET version 4.5.2, 4.6, or 4.6.1 must install a newer version of the Microsoft Framework if they want Microsoft to support the framework through future product updates. According to Microsoft, all three frameworks will cease support on April 26, 2022. After the support date ends, the product will not receive "security fixes or technical support." Most home devices are kept up to date through Windows updates. These devices already have newer versions of frameworks installed, such as .NET Framework 4.8. Devices that are not updating automatically may

PHP Implementation Framework: Zend Framework Getting Started Tutorial PHP Implementation Framework: Zend Framework Getting Started Tutorial Jun 19, 2023 am 08:09 AM

PHP implementation framework: ZendFramework introductory tutorial ZendFramework is an open source website framework developed by PHP and is currently maintained by ZendTechnologies. ZendFramework adopts the MVC design pattern and provides a series of reusable code libraries to serve the implementation of Web2.0 applications and Web Serve. ZendFramework is very popular and respected by PHP developers and has a wide range of

How to use ACL (Access Control List) for permission control in Zend Framework How to use ACL (Access Control List) for permission control in Zend Framework Jul 29, 2023 am 09:24 AM

How to use ACL (AccessControlList) for permission control in Zend Framework Introduction: In a web application, permission control is a crucial function. It ensures that users can only access the pages and features they are authorized to access and prevents unauthorized access. The Zend framework provides a convenient way to implement permission control, using the ACL (AccessControlList) component. This article will introduce how to use ACL in Zend Framework

KB5012643 for Windows 11 breaks .NET Framework 3.5 apps KB5012643 for Windows 11 breaks .NET Framework 3.5 apps May 09, 2023 pm 01:07 PM

It's been a week since we talked about the new safe mode bug affecting users who installed KB5012643 for Windows 11. This pesky issue didn't appear on the list of known issues Microsoft posted on launch day, thus catching everyone by surprise. Well, just when you thought things couldn't get any worse, Microsoft drops another bomb for users who have installed this cumulative update. Windows 11 Build 22000.652 causes more problems So the tech company is warning Windows 11 users that they may experience problems launching and using some .NET Framework 3.5 applications. Sound familiar? But please don't be surprised

How to fix 0xc0000135 error on Windows 11 (solve KB5013943 update issues) How to fix 0xc0000135 error on Windows 11 (solve KB5013943 update issues) May 11, 2023 am 08:28 AM

What is the 0xc0000135 error and why do I get it? According to official Microsoft documentation, the 0xc0000135 error code is related to .NetFramework issues. It seems that many applications that require .NetFramework3.5 to work do not work with the latest Windows 11 update. This is what causes the 0xc0000135 error code and you can resolve this issue by enabling .NetFramework3.5 on your PC. Most modern applications rely on the .NetFramework.dll file to run as expected in the background. but

See all articles