$Id: dbtree.class.php,v 2.0 2005/09/09 19:32:45 Kuzma Exp $
Copyright (C) 2005 Kuzma Feskov <kuzma@russofile.ru>
KF_SITE_VERSION
CLASS DESCRIPTION: This class can be used to manipulate nested sets of database table records that form an hierarchical tree.
It provides means to initialize the record tree, insert record nodes in specific tree positions, retrieve node and parent records, change position of nodes and delete record nodes.
It uses ANSI SQL statements and abstract DB libraryes, such as: ADODB Provides full functionality of the class: to make it work with many database types, support transactions, and caching of SQL queries to minimize database access overhead DB_MYSQL The class-example showing variant of creation of the own engine for dialogue with a database, it's emulate some ADODB functions (ATTENTION, class only shows variant of a spelling of the driver, use it only as example)
The library works with support multilanguage interface of technology GetText (GetText autodetection).
This source file is part of the KFSITE Open Source Content Management System.
This file may be distributed and/or modified under the terms of the "GNU General Public License" version 2 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file.
This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
The "GNU General Public License" (GPL) is available at http://www.gnu.org/copyleft/gpl.html.
CHANGELOG:
v2.0
[+] GetText autodetect added
[+] DB libraries abstraction added
Located in /dbtree.class.php (line 54)
Databse layer object.
Detailed errors of a class (for the programmer and log-files) array('error type (1 - fatal (write log), 2 - fatal (write log, send email)', 'error info string', 'function', 'info 1', 'info 2').
The information on a error for the user array('string (error information)').
DB resource object.
Name of the table where tree is stored.
Unique number of node.
Level of nesting.
The class constructor: initializes dbtree variables.
Returns a slightly opened tree from an element with number $ID.
Returns all elements of a branch starting from an element with number $ID.
Change items position.
Swapping nodes within the same level and limits of one parent with all its children: $id1 placed before or after $id2.
Sets initial parameters of a tree and creates root of tree ATTENTION, all previous values in table are destroyed.
Delete element with number $id from the tree wihtout deleting it's children.
Delete element with number $ID from the tree and all it childret.
Returns all elements of the tree sortet by left.
Receives left, right and level for unit with number id.
Receives parent left, right and level for unit with number $id.
Add a new element in the tree to element with number $section_id.
Add a new element in the tree near element with number id.
Assigns a node with all its children to another parent.
Returns all parents of element with number $ID.
Transform array with conditions to SQL query Array structure: array('and' => array('id = 0', 'id2 >= 3'), 'or' => array('sec = \'www\'', 'sec2 <> \'erere\'')), etc where array key - condition (AND, OR, etc), value - condition string.
Documentation generated on Fri, 16 Sep 2005 16:45:04 +0400 by phpDocumentor 1.3.0RC3