Zend_Paginator 与 Zend_Db_Table_Abstract 的结果
我在模型目录中有许多类,它们是 Zend_Db_Table_Abstract 的扩展。
但我需要使用 zend_paginator 并且这需要 Zend_Db_Select 的结果!
所以当我使用这段代码时(productCat 是一个模型类)
$productCat = new ProductCat();
$rows = $productCat->FetchOrderByPriority();
// Get a Paginator object using Zend_Paginator's built-in factory.
$paginator = Zend_Paginator::factory($rows);
$this->view->paginator = $paginator;
它不起作用!
它向我显示此错误:
Catchable fatal error: Object of class Zend_Db_Table_Row could not be converted to string in
这是我的视图代码:
<ul><?php foreach ($this->paginator as $item): ?>
<li><?php echo $item; ?></li><?php endforeach; ?></ul>
有什么想法吗?
i have many class in model directory that those are extend of Zend_Db_Table_Abstract.
but i need use of zend_paginator and this need to result of Zend_Db_Select !!
so when i use of this code (productCat is a model class)
$productCat = new ProductCat();
$rows = $productCat->FetchOrderByPriority();
// Get a Paginator object using Zend_Paginator's built-in factory.
$paginator = Zend_Paginator::factory($rows);
$this->view->paginator = $paginator;
it don`t work!
it show me this error :
Catchable fatal error: Object of class Zend_Db_Table_Row could not be converted to string in
this is my view code :
<ul><?php foreach ($this->paginator as $item): ?>
<li><?php echo $item; ?></li><?php endforeach; ?></ul>
is there any idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
分页绝对有效。问题出在您试图
echo $item
的位置。显然它不起作用,因为
Zend_Paginator::factory($rows)
返回了一个行集;因此,当您迭代$paginator
对象时,您将获得Zend_Db_Table_Row
类型的对象,并且您根本无法echo
它们。我相信,您要做的就是
echo
item
对象的特定属性,例如:Pagination definitely works. The problem is in your view where you're trying to
echo $item
.And it obviously doesn't work since
Zend_Paginator::factory($rows)
has returned a rowset; so when you're iterating over$paginator
object, you're getting objects ofZend_Db_Table_Row
type, and you simply cannotecho
them.What you're trying to do, I believe, is to
echo
a particular property of theitem
object, something like: