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?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?