Login   Register  
PHP Classes
elePHPant
Icontem

File: README.txt

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Nikola Posa  >  Nested Set DB Table  >  README.txt  >  Download  
File: README.txt
Role: Documentation
Content type: text/plain
Description: Readme file.
Class: Nested Set DB Table
Manage nested sets of data stored in a database
Author: By
Last change: New version
Date: 3 years ago
Size: 2,247 bytes
 

Contents

Class file image Download
NestedSetDbTable is a abstract class that provides API for managing 
some table which has data that is organized in "Nested set model" 
manner.

Developers should extend this class in order to use its functionality.
Properties $_name (name of the table), $_primary (name of the primary key),
$_left (left column name in nested table) and $_right (right column name
in nested table) must be overrriden in the extending class and filled with
appropriate values.

PDO instance must be supplied to the object of this class in order to
use it.

AUTHOR
------
Nikola Posa <posa.nikola@gmail.com>

INSTALLATION
------------
1. You should put folder, in which you've stored NestedSetDbTable dir, in
the include path. Here's an example of how to do that:

	set_include_path('.' . PATH_SEPARATOR . 'path/to/libs' 
		. PATH_SEPARATOR . get_include_path());

... where "libs" is name of the folder where you've stored NestedSetDbTable dir. 

FEATURES
--------
* API for managing database table, which has data that is organized 
  in "Nested set model" manner,

* Methods for implementing Nested set model,

* getTree() method gets whole tree, including depth information,

* insert() method enables adding new node at desired position in 
  tree hierarchy,

* updateNode() method enables updating data of some node, including 
  its position in tree hierarchy,

* deleteNode() method is used for deleting nodes, and it has option 
  for deleting only desired node (without its child nodes), or 
  deleting its child nodes as well

USAGE
-----
class Categories extends NestedSetDbTable_Abstract
{
    protected $_name = 'categories';

    protected $_primary = 'id';

    protected $_left = 'left';

    protected $_right = 'right';
}

$pdo = new PDO('mysql:dbname=test;host=127.0.0.1', 'root', '');

//Setting db adapter for all instances of NestedSetDbTable_Abstract class:
NestedSetDbTable_Abstract::setDefaultAdapter($pdo);

$categories = new Categories();
print_r($categories->getTree());

SYSTEM REQUIREMENTS
-------------------
NestedSetDbTable package requires PHP 5 or later, with enabled PDO extension.

LICENSE
-------
The files in this archive are released under the GNU General Public License. 
You can find a copy of this license in LICENSE.txt.