开发者

Zend Pagination changing value injection

开发者 https://www.devze.com 2023-01-08 00:18 出处:网络
In Zend_Paginator I am trying to change one of the values of the paginator object after the database result

In Zend_Paginator

I am trying to change one of the values of the paginator object after the database result

I loop through the paginator - get the item an then sent the 开发者_StackOverflow社区rank

However this is not carrying forward to the view pagination and rank is NULL

    // Loop through the results and get the users Rank
    foreach ($paginator as $k => $v) {

        $rowSet       = $paginator->getItem($i);
        $rowSet->rank = $table->getRanking($rowSet->score);

        echo $rowSet->first_name . '<br />';
        echo $rowSet->rank . '<br />';

        $i++;
    }

    $this->view->paginator = $paginator;


Just use Paginator iterator like this:

foreach ( $paginator as &$item )
{
    $item->rank = $table->getRanking($item->score);
}

Please note the &$item which makes the $item an reference to the actual $item not the copy of the $item.


That is really not the way you are supposed to use foreach loops. You do not even use $k or $v inside the foreach. link text

0

精彩评论

暂无评论...
验证码 换一张
取 消