CakePHP-ClosureBehavior

An efficient alternative to CakePHP Tree Behavior

  • 所有者: ProLoser/CakePHP-ClosureBehavior
  • 平台:
  • 许可证:
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

CakePHP Closure Behavior

An efficient alternative to the CakePHP Tree Behavior

Background

I was working on a project, where I listed multiple posts on the homepage and wanted to show the categories they fell under as breadcrumbs. Normally the tree behavior works just fine, but if I have 40 posts, I now do 1 query for the list of posts and 40 queries to get a list of all ancestor categories for the post. This didn't seem like a good idea, so I started to look for ways around this. generateTreeList and an iterator function seemed more viable, cutting my query down to 2, but the function itself would prove to be complex and slow.

After searching for feedback on irc.freenode.net/php someone pointed me to an interesting slideshow where I learned about the 'Closure' pattern (page 68). It seems to be a much more efficient alternative to MPTT. So this is my attempt to implement it.

An interesting example implementation: http://codepad.org/pR5r68V0

Installation

With Git

git submodule add git@github.com:ProLoser/CakePHP-ClosureBehavior.git Plugin/Closure

Without Git

Download package and extract to Plugin/Closure

主要指标

概览
名称与所有者ProLoser/CakePHP-ClosureBehavior
主编程语言PHP
编程语言PHP (语言数: 1)
平台
许可证
所有者活动
创建于2012-01-09 06:47:05
推送于2012-02-05 09:58:49
最后一次提交2012-02-05 01:58:43
发布数0
用户参与
星数14
关注者数2
派生数0
提交数3
已启用问题?
问题数0
打开的问题数0
拉请求数0
打开的拉请求数0
关闭的拉请求数0
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?