标题: 想问一下有没有人做过分页?
wohugb
PHPEye Developer
Rank: 8Rank: 8



UID 216
精华 0
积分 0
帖子 20
翻译 0
原创 0
阅读权限 1
注册 2007-7-23
状态 离线
发表于 2007-8-15 01:46  资料  主页 短消息  加为好友  添加 wohugb 为MSN好友 通过MSN和 wohugb 交谈
想问一下有没有人做过分页?

如题,我找了哥分页类Riskle_Db_Table_Paginate ,但却不会使用,按照他的提示
And here is how it is used in the controller:

     public function indexAction() {
         $urls = new Riskle_Db_Table_Paginate(new Urls, $this->_getParam('page'));
         $this->view->urlsList = $urls->fetchAll(null, 'datetime DESC');
         $this->view->paginationInfos = $urls->getPaginationInfos();
     }

The view helper takes paginationInfos as an argument:

echo $this->paginate($this->paginationInfos);


,但不知道这个urls是什么东西?

顶部
liyong98847
新手上路
Rank: 1



UID 571
精华 0
积分 0
帖子 7
翻译 0
原创 6
阅读权限 10
注册 2007-11-16
状态 离线
发表于 2007-11-16 17:23  资料  短消息  加为好友 
public function indexAction()
    {
                $this->view->title = "Co. Albums";
                $Album = new Album();
               
        // Define limit
        $count = 5;
        // Get total rows
        $totalRows = $Album->fetchAll()->count();           
        // Get total pages
        $totalPages = ceil($totalRows / $count);
            // Define current page
        $page = (int)$this->_getParam("page");
            if ($page < 1 || $page > $totalPages) $page = 1;
            // Define offset
            $offset = ($page - 1) * $count;
               
        $this->view->totalRows   = $totalRows;
        $this->view->totalPages  = $totalPages;
        $this->view->offset      = $offset;
        $this->view->count       = $count;
        $this->view->page        = $page;
            $this->view->albums      = $Album->fetchAll(null, null, $count, $offset)->toArray();
        }

顶部
liyong98847
新手上路
Rank: 1



UID 571
精华 0
积分 0
帖子 7
翻译 0
原创 6
阅读权限 10
注册 2007-11-16
状态 离线
发表于 2007-11-16 17:24  资料  短消息  加为好友 
你还是看看上面这段代码吧

顶部
 


PHPEye开源社区


当前时区 GMT+8, 现在时间是 2009-1-9 08:13

    Powered by Discuz! 5.5.0  © 2001-2007 Comsenz Inc.
Processed in 0.020956 second(s), 6 queries , Gzip enabled

清除 Cookies - 联系我们 - PHPEye开源社区 - Archiver