harp-orm / materialized-path
为Harp ORM模型实现物化路径嵌套
0.3.1
2014-07-17 15:50 UTC
Requires
- php: >=5.4.0
- harp-orm/harp: ~0.3.0
README
为Harp ORM模型实现物化路径嵌套。
什么是物化路径?这里有很好的解释:[链接](http://bojanz.wordpress.com/2014/04/25/storing-hierarchical-data-materialized-path/)。这个包不实现最先进的实现,但它按目前的状态运行得相当好。
使用方法
将特性添加到您的模型中
use Harp\Harp\AbstractModel; use Harp\MP\MaterializedPathTrait; class Category extends AbstractModel { public static function initialize($config) { MaterializedPathTrait::initialize($config); // Other initializations // ... } }
数据库表
┌─────────────────────────┐
│ Table: Category │
├─────────────┬───────────┤
│ id │ ingeter │
│ name │ string │
│ parentId* │ integer │
│ path* │ string │
└─────────────┴───────────┘
* Required fields
方法
它将为仓库添加 "parent" 和 "children" Rels。模型将获得便利的方法
许可协议
版权 (c) 2014, Clippings Ltd. 由 Ivan Kerin 开发
在 BSD-3-Clause 许可协议下,请参阅 LICENSE 文件。