Kohana 3.0 分页器不分页

发布于 2024-11-26 22:51:56 字数 902 浏览 3 评论 0原文

我的 kohana 分页有问题。我已经制定了一种对数据库中的元素进行分页的方法(假设一页上有 3 个元素),但是(尽管分页链接在那里),分页实际上并未完成,这意味着我总是列出查询的所有元素。 我正在使用的代码:

  1. 在助手中:

     公共函数 come_paginate_users(){
     $count = Model::factory('user')->count_all(); //回显$count;出口();
    
    $分页 = 分页::工厂(数组(
    'total_items'=>; $计数,
    'items_per_page' =>; 2、
    '自动隐藏' =>真的,
    
     ));
    
    $results = Model::factory('user')->order_by('user_id','ASC')->limit($pagination->items_per_page)->offset($pagination->offset)- >find_all();//->execute();
    
     $page_links = $pagination->render();
     返回$分页;
         }
    

在控制器中:

                $pagination = @helper_utilities::come_paginate_users();
                $this->view->pagination = $pagination;

在视图中:

               <? echo 'Classic style: '.$pagination;?>

但是...分页不起作用。知道为什么吗?谢谢你!

i have a problem with the kohana pagination. i have made a method for paginating elements from the database, (let's say 3 on a page), but, (though the pagination links are there), the pagination is not actually done, meaning i always get listed all the elements of the query.
the code i am using:

  1. in a helper:

     public function come_paginate_users(){
     $count = Model::factory('user')->count_all(); //echo $count; exit();
    
    $pagination = Pagination::factory(array(
    'total_items'    => $count,
    'items_per_page' => 2,
    'auto_hide'      => TRUE,
    
     ));
    
    $results = Model::factory('user')->order_by('user_id','ASC')->limit($pagination-                     >items_per_page)->offset($pagination->offset)->find_all();//->execute();
    
     $page_links = $pagination->render();
     return $pagination;
         }
    

in the controller:

                $pagination = @helper_utilities::come_paginate_users();
                $this->view->pagination = $pagination;

and in the view:

               <? echo 'Classic style: '.$pagination;?>

but... the pagination is not working. any idea why? thank you!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

岛歌少女 2024-12-03 22:51:56

实际上,您需要在 come_paginate_users() 方法中返回 $page_links (呈现 html)和 $result 而不是 $pagination 对象

Actually, You need to return $page_links (wich is rendered html) and $result instead of $pagination object in your come_paginate_users() method

删除→记忆 2024-12-03 22:51:56

也许total_items total_items total_items total_items total_items items_per_pageauto_hide 隐藏分页?尝试将 auto_hide 设置为 FALSE

Maybe total_items < items_per_page and auto_hide hides the pagination? Try to set auto_hide to FALSE

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文