aidask / yii-closure-table-behavior
ActiveRecord model behavior that allows to work with tree data.
Installs: 172
Dependents: 0
Suggesters: 0
Security: 0
Stars: 17
Watchers: 3
Forks: 4
Open Issues: 0
Type:yii-extension
Requires
- php: >=5.1.0
- yiisoft/yii: 1.*@dev
This package is auto-updated.
Last update: 2024-10-25 06:39:40 UTC
README
Extension allows managing trees stored in database.
Configuration
Add behavior to model as follows:
public function behaviors() { return array( 'closureTableBehavior'=>array( 'class'=>'ext.ClosureTableBehavior', 'closureTableName'=>'table_name', ) ); }
Examples
Model configuration: /tests/models/Folder.php
Schema example: /tests/schema/db.sql
Behavior usage: /tests/unit/ClosureTableBehaviorTest.php
Contribution
Your participation to Yii Closure Table behavior development is very welcome!
To ensure consistency throughout the source code, keep these rules in mind as you are working:
- All features or bug fixes must be tested by one or more specs.
- Your code should follow PSR-2 coding style guide
Literature:
http://www.slideshare.net/billkarwin/models-for-hierarchical-data
http://www.mysqlperformanceblog.com/2011/02/14/moving-subtrees-in-closure-table/