Giter VIP home page Giter VIP logo

orm-mptt's Introduction

Modified Preorder Traversal Tree for Kohana 3.3 ORM

A port of Banks' Sprig_MPTT plus some code from BIakaVeron's ORM_MPTT module.

ISC License

Setup

Place module in /modules/ and include the call in your bootstrap.

Declaring your ORM object

class Model_Category extends ORM_MPTT {
}

Usage Examples

Creating a root node:

$cat = ORM::factory('Category_Mptt');
$cat->name = 'Music';
$cat->insert_as_new_root();
echo 'Category ID'.$mptt->id.' set at level '.$cat->lvl.' (scope: '.$cat->scope.')';
$c1 = $cat; // Saving id for next example

Creating a child node:

$cat->clear(); // Clearing ORM object
$cat->name = 'Terminology';
$cat->insert_as_last_child($c1);

Running unit tests

You need the test table inside your default database connection to run unit tests.

CREATE TABLE `test_orm_mptt` (
	`id` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
	`parent_id` INT UNSIGNED NULL,
	`lft` INT UNSIGNED NOT NULL,
	`rgt` INT UNSIGNED NOT NULL,
	`lvl` INT UNSIGNED NOT NULL,
	`scope` INT UNSIGNED NOT NULL
) ENGINE=INNODB;

Authors

  • Mathew Davies
  • Kiall Mac Innes
  • Paul Banks
  • Brotkin Ivan
  • Brandon Summers
  • Alexander Yakovlev
  • Matthias Lill

orm-mptt's People

Contributors

evopix avatar l1lle avatar rafi avatar oreolek avatar erralb avatar flody avatar

Stargazers

 avatar

Watchers

 avatar Szymon avatar  avatar

Forkers

inurosen

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.