2017 © Pedro Pelรกez
 

library materialized-path

Materialized path nesting for Harp ORM models

image

harp-orm/materialized-path

Materialized path nesting for Harp ORM models

  • Thursday, July 17, 2014
  • by hkdobrev
  • Repository
  • 2 Watchers
  • 1 Stars
  • 136 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

Materialized Path

Build Status Scrutinizer Code Quality Code Coverage Latest Stable Version, (*1)

Materialized path nesting for Harp ORM models., (*2)

What is Materialized path? Here's a great explanation: http://bojanz.wordpress.com/2014/04/25/storing-hierarchical-data-materialized-path/ This package does not implement the most advanced implementation, but it works quite well as is., (*3)

Usage

Add the Trait to your Model, (*4)

use Harp\Harp\AbstractModel;
use Harp\MP\MaterializedPathTrait;

class Category extends AbstractModel
{
    public static function initialize($config)
    {
        MaterializedPathTrait::initialize($config);

        // Other initializations
        // ...
    }
}

Database Table:, (*5)

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Table: Category         โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ id          โ”‚ ingeter   โ”‚
โ”‚ name        โ”‚ string    โ”‚
โ”‚ parentId*   โ”‚ integer   โ”‚
โ”‚ path*       โ”‚ string    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
* Required fields

Methods

It will add "parent" and "children" Rels to the repo. The model will get the convenience methods:, (*6)

Method Description
getParent() Return the immidiate parent model
setParent(AbstractModel $parent) Set the immidiate parent model, after save the changes are propogated to all the children
getChildren() Get immidiate children. Returns a Models object
isRoot() Boolean check if it is root (has parent) or not
getDescendants() Returns all the children and the children's children. Models object
getAnsestors() Return all the parents, including root. Models object
isDescendantOf(AbstractModel $parent) Chech if a model is descendant
isAnsestorOf(AbstractModel $parent) Chech if model is ansestor

License

Copyright (c) 2014, Clippings Ltd. Developed by Ivan Kerin, (*7)

Under BSD-3-Clause license, read LICENSE file., (*8)

The Versions

17/07 2014

dev-master

9999999-dev

Materialized path nesting for Harp ORM models

  Sources   Download

BSD-3-Clause

The Requires

 

17/07 2014

0.3.1

0.3.1.0

Materialized path nesting for Harp ORM models

  Sources   Download

BSD-3-Clause

The Requires

 

14/07 2014

0.3.0

0.3.0.0

Materialized path nesting for Harp ORM models

  Sources   Download

BSD-3-Clause

The Requires

 

09/07 2014

0.2.0

0.2.0.0

Materialized path nesting for Harp ORM models

  Sources   Download

BSD-3-Clause

The Requires

 

01/07 2014

0.1.1

0.1.1.0

Materialized path nesting for Harp ORM models

  Sources   Download

BSD-3-Clause

The Requires

 

26/06 2014

0.1.0

0.1.0.0

Materialized path nesting for Harp ORM models

  Sources   Download

BSD-3-Clause

The Requires