Kohana 3.0 分页器不分页
我的 kohana 分页有问题。我已经制定了一种对数据库中的元素进行分页的方法(假设一页上有 3 个元素),但是(尽管分页链接在那里),分页实际上并未完成,这意味着我总是列出查询的所有元素。 我正在使用的代码:
在助手中:
公共函数 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:
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
实际上,您需要在 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
也许
total_items
total_items
total_items
total_items
total_items
items_per_page
和auto_hide
隐藏分页?尝试将auto_hide
设置为FALSE
Maybe
total_items
<items_per_page
andauto_hide
hides the pagination? Try to setauto_hide
toFALSE