Zeta Components - high quality PHP components

Zeta Components Manual :: Docs For Class ezcTreeDb

TreeDatabaseTiein::ezcTreeDb

Class ezcTreeDb

ezcTreeDb contains common methods for the different database tree backends.

Source for this file: /TreeDatabaseTiein/src/backends/db.php

ezcTree
   |
   --ezcTreeDb
Version:   //autogentag//

Descendants

Child Class Description
ezcTreeDbMaterializedPath ezcTreeDbMaterializedPath implements a tree backend which stores parent/child information in a path like string (such as /1/4/6/8).
ezcTreeDbParentChild ezcTreeDbParentChild implements a tree backend which stores parent/child information in a simple table containing the node's ID and its parent's ID.

Properties

string read/write $nodeClassName
Which class is used as tree node - this class *must* inherit the ezcTreeNode class.
ezcTreeDbDataStore read $store
The data store that is used for retrieving/storing data.

Member Variables

protected ezcDbHandler $dbh
Contains the database connection handler.
protected string $indexTableName
Contains the name of the table to retrieve the relational data from.

Inherited Member Variables

From ezcTree
protected ezcTree::$inTransaction
protected ezcTree::$inTransactionCommit
protected ezcTree::$properties

Method Summary

public ezcTreeDb __construct( $dbh , $indexTableName , $store )
Constructs a new ezcTreeDb object.
protected abstract ezcQueryInsert createAddEmptyNodeQuery( )
Creates the query to insert an empty node into the database, so that the last-inserted ID can be obtained.
protected ezcQuery createAddNodeQuery( $id )
Creates the query to insert/update an empty node in the database.
public ezcTreeNode fetchParent( $id )
Returns the parent node of the node with ID $id.
protected integer generateNodeID( )
This method generates the next node ID.
protected string getParentId( $childId )
Returns the ID of parent of the node with ID $childId.
public ezcTreeNode getRootNode( )
Returns the root node.
public bool nodeExists( $id )
Returns whether the node with ID $id exists as tree node.

Inherited Methods

From ezcTree
public void ezcTree::accept()
Implements the accept method for visiting.
public abstract void ezcTree::addChild()
Adds the node $childNode as child of the node with ID $parentId.
protected void ezcTree::addTransactionItem()
Adds a new transaction item to the list.
public void ezcTree::beginTransaction()
Starts an transaction in which all tree modifications are queued until the transaction is committed with the commit() method.
protected void ezcTree::checkNodeId()
This method checks whether a node ID is valid to be used in a backend.
public void ezcTree::commit()
Commits the transaction by running the stored instructions to modify the tree structure.
public static void ezcTree::copy()
Copies the tree in $from to the empty tree in $to.
public ezcTreeNode ezcTree::createNode()
Creates a new tree node with node ID $nodeId and $data.
public abstract void ezcTree::delete()
Deletes the node with ID $nodeId from the tree, including all its children.
public abstract ezcTreeNodeList ezcTree::fetchChildren()
Returns all the children of the node with ID $nodeId.
public ezcTreeNode ezcTree::fetchNodeById()
Returns the node identified by the ID $nodeId.
public abstract ezcTreeNode ezcTree::fetchParent()
Returns the parent node of the node with ID $nodeId.
public abstract ezcTreeNodeList ezcTree::fetchPath()
Returns all the nodes in the path from the root node to the node with ID $nodeId, including those two nodes.
public abstract ezcTreeNodeList ezcTree::fetchSubtree()
Alias for fetchSubtreeDepthFirst().
public abstract ezcTreeNodeList ezcTree::fetchSubtreeBreadthFirst()
Returns the node with ID $nodeId and all its children, sorted according to the Breadth-first sorting algorithm.
public abstract ezcTreeNodeList ezcTree::fetchSubtreeDepthFirst()
Returns the node with ID $nodeId and all its children, sorted according to the Depth-first sorting algorithm.
protected abstract integer ezcTree::generateNodeID()
This method generates the next node ID.
public abstract int ezcTree::getChildCount()
Returns the number of direct children of the node with ID $nodeId.
public abstract int ezcTree::getChildCountRecursive()
Returns the number of children of the node with ID $nodeId, recursively.
public abstract int ezcTree::getPathLength()
Returns the distance from the root node to the node with ID $nodeId.
public abstract ezcTreeNode ezcTree::getRootNode()
Returns the root node.
public abstract bool ezcTree::hasChildNodes()
Returns whether the node with ID $nodeId has children.
public bool ezcTree::inTransaction()
Returns whether we are currently in a transaction or not
public bool ezcTree::inTransactionCommit()
Returns whether we are currently in a transaction commit state or not
public abstract bool ezcTree::isChildOf()
Returns whether the node with ID $childId is a direct child of the node with ID $parentId.
public abstract bool ezcTree::isDescendantOf()
Returns whether the node with ID $childId is a direct or indirect child of the node with ID $parentId.
public abstract bool ezcTree::isSiblingOf()
Returns whether the nodes with IDs $child1Id and $child2Id are siblings (ie, they share the same parent).
public abstract void ezcTree::move()
Moves the node with ID $nodeId as child to the node with ID $targetParentId.
public abstract bool ezcTree::nodeExists()
Returns whether the node with ID $nodeId exists.
public void ezcTree::rollback()
Rolls back the transaction by clearing all stored instructions.
public abstract void ezcTree::setRootNode()
Sets a new node as root node, this also wipes out the whole tree.

Methods

__construct

ezcTreeDb __construct( $dbh , string $indexTableName , ezcTreeDbDataStore $store )

Constructs a new ezcTreeDb object.

The different arguments to the constructor configure which database connection ($dbh) is used to access the database and the $indexTableName argument which table is used to retrieve the relation data from. The $store argument configure which data store is used with this tree.

All database backends require the index table to at least define the field 'id', which can either be a string or an integer field.

Parameters:
Name Type Description
$dbh ezcDbHandler
$indexTableName string
$store ezcTreeDbDataStore
Redefined in descendants as:
Method Description
ezcTreeDbMaterializedPath::__construct() Constructs a new ezcTreeDbMaterializedPath object. 

createAddEmptyNodeQuery

ezcQueryInsert createAddEmptyNodeQuery( )

Creates the query to insert an empty node into the database, so that the last-inserted ID can be obtained.

Redefined in descendants as:
Method Description
ezcTreeDbMaterializedPath::createAddEmptyNodeQuery() Creates the query to insert an empty node into the database, so that the last-inserted ID can be obtained. 
ezcTreeDbParentChild::createAddEmptyNodeQuery() Creates the query to insert an empty node into the database, so that the last-inserted ID can be obtained. 
ezcTreeDbNestedSet::createAddEmptyNodeQuery() Creates the query to insert an empty node into the database, so that the last-inserted ID can be obtained. 

createAddNodeQuery

ezcQuery createAddNodeQuery( mixed $id )

Creates the query to insert/update an empty node in the database.

The query is constructed for the child with ID $id

Parameters:
Name Type Description
$id mixed

fetchParent

ezcTreeNode fetchParent( string $id )

Returns the parent node of the node with ID $id.

This method returns null if there is no parent node.

Parameters:
Name Type Description
$id string
Redefinition of:
Method Description
ezcTree::fetchParent() Returns the parent node of the node with ID $nodeId.

generateNodeID

integer generateNodeID( )

This method generates the next node ID.

It does so by inserting a new empty node into the database, and uses lastInsertId() to obtain the ID for the newly inserted node.

Redefinition of:
Method Description
ezcTree::generateNodeID() This method generates the next node ID.

getParentId

string getParentId( string $childId )

Returns the ID of parent of the node with ID $childId.

Parameters:
Name Type Description
$childId string

getRootNode

ezcTreeNode getRootNode( )

Returns the root node.

This methods returns null if there is no root node.

Redefinition of:
Method Description
ezcTree::getRootNode() Returns the root node.

nodeExists

bool nodeExists( string $id )

Returns whether the node with ID $id exists as tree node.

Parameters:
Name Type Description
$id string
Redefinition of:
Method Description
ezcTree::nodeExists() Returns whether the node with ID $nodeId exists.
Documentation generated by phpDocumentor 1.4.3