PHPackages                             closure/lugege - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. closure/lugege

ActiveLibrary

closure/lugege
==============

基于TP5 closure

14PHP

Since Apr 17Pushed 5y ago1 watchersCompare

[ Source](https://github.com/daniel110119/Closure)[ Packagist](https://packagist.org/packages/closure/lugege)[ RSS](/packages/closure-lugege/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

About
-----

[](#about)

优雅的树形数据结构管理包,基于`Closure Table`模式设计.

依赖
--

[](#依赖)

- php &gt; 5.6.0
- mysql &gt; 5.1.0
- tp5.0

关于`Closure Table`
-----------------

[](#关于closure-table)

> Closure table is a simple and elegant way of storing and querying hierarchical data in any RDBMS. By hierarchical data we mean a set of data that has some parent – child relationship among them. We use the word ‘tree’ instead of hierarchies commonly. As an example we may take the relationships between geographic locations like ‘Countries’, ‘States/ Province’, ‘Districts/ Cities’ etc.

`Closure Table`将树中每个节点与其后代节点的关系存储在数据库中, 这将需要一个存储节点关系的表`xxx_closure`.

例如一个菜单表`menus`:

idnameparent1A02AA13AB14AAA25ABA36ABAA5一个基本的`closure`表包含`ancestor`,`descendant`,`distance`3个字段,如:

ancestordescendantdistance110121131142152163220241330351362440550561660这个表记录了每个节点之间的关系,并且还记录了一条自身的关联,如：`1,1,0`.

使用
--

[](#使用)

`ClosureTable`提供了大量方法操作树结构.

### 影响树结构的方法

[](#影响树结构的方法)

```
