Php 如何使用zend分页

Php 如何使用zend分页,php,database,zend-framework,pagination,zend-paginator,Php,Database,Zend Framework,Pagination,Zend Paginator,我想在zend framework1中分页, 在模型中,我声明了Books.php(application/models/Books.php): لیست 身份证件 用户名 领域 密码 电子邮件地址 ha1 ha1b 如何以每页10条记录的限制分页信息?尝试稍微更改控制器的操作代码: public function listAction() { $request = $this->getRequest(); $page = $request->getParam(

我想在zend framework1中分页,
在模型中,我声明了Books.php(application/models/Books.php):


لیست
身份证件
用户名
领域
密码
电子邮件地址
ha1
ha1b

如何以每页10条记录的限制分页信息?

尝试稍微更改控制器的操作代码:

public function listAction() 
{
    $request = $this->getRequest();
    $page = $request->getParam('page', 1);

    $booksModel = new Model_Books();
    $select = $booksModel->select();
    $paginator = new Zend_Paginator(new Zend_Paginator_Adapter_DbTableSelect($select));
    $paginator->setCurrentPageNumber($page);
    $paginator->setItemCountPerPage(10);

    $this->view->books = $paginator;
}
然后你可以像以前一样使用你的视图,但是,你可能需要在页面之间导航的按钮。基本paginator部分,在您的视图中使用,如Zend docs中所述:

<?php echo $this->paginationControl($this->paginator,
                                    'Sliding',
                                    'my_pagination_control.phtml'); ?>

请看-有许多与本课程相关的问题的答案

<?php echo $this->doctype() ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>لیست</title>
  <?php echo $this->headLink()->appendStylesheet('/css/global.css') ?>
</head>
<body>
 <div class="datagrid">
    <table style="border-collapse: collapse; text-align: center; width: 100%;">
      <tr>
        <th>id</th>
        <th>username</th>
        <th>domain</th>
        <th>password</th>
        <th>email address</th>
        <th>ha1</th>
        <th>ha1b</th>
      </tr>

        <?php 
            foreach ($this ->books as $key =>$value)
            {

                echo '<tr><td>'.$value->id.'</td><td>'.$value->username.'</td><td>'.
                $value->domain.'</td><td>'.$value->password.'</td><td>'.$value->email_address
                .'-</td><td>'.$value->ha1.'</td><td>'.$value->ha1b.'</td></tr>';
            }
        ?>
  </table>
 </div>
</body>
</html>
public function listAction() 
{
    $request = $this->getRequest();
    $page = $request->getParam('page', 1);

    $booksModel = new Model_Books();
    $select = $booksModel->select();
    $paginator = new Zend_Paginator(new Zend_Paginator_Adapter_DbTableSelect($select));
    $paginator->setCurrentPageNumber($page);
    $paginator->setItemCountPerPage(10);

    $this->view->books = $paginator;
}
<?php echo $this->paginationControl($this->paginator,
                                    'Sliding',
                                    'my_pagination_control.phtml'); ?>