Zend_Paginator 与 Zend_Db_Table_Abstract 的结果

发布于 2024-11-03 01:11:04 字数 787 浏览 5 评论 0原文

我在模型目录中有许多类,它们是 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 技术交流群。

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

发布评论

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

评论(1

作妖 2024-11-10 01:11:04

分页绝对有效。问题出在您试图 echo $item 的位置。

显然它不起作用,因为 Zend_Paginator::factory($rows) 返回了一个行集;因此,当您迭代 $paginator 对象时,您将获得 Zend_Db_Table_Row 类型的对象,并且您根本无法echo 它们。

我相信,您要做的就是echo item 对象的特定属性,例如:

echo $item->name;

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 of Zend_Db_Table_Row type, and you simply cannot echo them.

What you're trying to do, I believe, is to echo a particular property of the item object, something like:

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