标题: 问一下插件怎么用?
bc1998
新手上路
Rank: 1



UID 588
精华 0
积分 0
帖子 32
翻译 0
原创 0
阅读权限 10
注册 2007-11-24
状态 离线
发表于 2007-12-23 16:36  资料  短消息  加为好友 
问一下插件怎么用?


顶部
haohappy
超级版主
Rank: 8Rank: 8
PHPEye站长


UID 2
精华 11
积分 110
帖子 283
翻译 6
原创 1
阅读权限 150
注册 2007-5-2
状态 离线
发表于 2007-12-23 18:01  资料  短消息  加为好友  添加 haohappy 为MSN好友 通过MSN和 haohappy 交谈
这不是什么插件呀,这个东西的功能就是要让Rowset可以递归遍历而已。





互助共享,共同成长。
顶部
bc1998
新手上路
Rank: 1



UID 588
精华 0
积分 0
帖子 32
翻译 0
原创 0
阅读权限 10
注册 2007-11-24
状态 离线
发表于 2007-12-24 06:54  资料  短消息  加为好友 


QUOTE:
原帖由 haohappy 于 2007-12-23 18:01 发表
这不是什么插件呀,这个东西的功能就是要让Rowset可以递归遍历而已。

那怎么用呢?

顶部
haohappy
超级版主
Rank: 8Rank: 8
PHPEye站长


UID 2
精华 11
积分 110
帖子 283
翻译 6
原创 1
阅读权限 150
注册 2007-5-2
状态 离线
发表于 2007-12-24 10:06  资料  短消息  加为好友  添加 haohappy 为MSN好友 通过MSN和 haohappy 交谈
你贴的这个只是一个Proposal(提案),还没有正式被ZF所采纳,还未实现,只是一个想法而已。

至于用法,网页中不是都有假想的示例代码吗?

先定义一个可以递归遍历的Rowset类:
class My_Db_Table_Rowset_Recursive extends Zend_Db_Table_Rowset_Recursive_Abstract
{
    protected $_childId = 'id';
    protected $_parentId = 'parent_id';
}

然后在Model中设定一下你使用的Rowset类为刚才定义的类:

class MyComments extends Zend_Db_Table_Abstract
{
    protected $_name = 'Comments';

    protected $_rowsetClass = 'My_Db_Table_Rowset_Recursive';

}

这样你就可以在View中根据需要设定遍历几层,(比如下面的例子中可以遍历三层):
<?php      
      $comments = new RecursiveIteratorIterator($this->comments);
      foreach($comments as $comment):  
      //We can use the getDepth() method to determine the depth of the recursive iteration
?>
<div style="margin-left: <?php echo ($comments->getDepth() * 3);?>px;">
<?php echo $comment->comment; ?>
</div>
<?php endforeach; ?>
}





互助共享,共同成长。
顶部
 


PHPEye开源社区


当前时区 GMT+8, 现在时间是 2008-12-5 09:17

    Powered by Discuz! 5.5.0  © 2001-2007 Comsenz Inc.
Processed in 0.028304 second(s), 6 queries , Gzip enabled

清除 Cookies - 联系我们 - PHPEye开源社区 - Archiver