Class JTableNested

Description

Table class supporting modified pre-order tree traversal behavior.

Located in /libraries/joomla/table/nested.php (line 20)

JObject
   |
   --JTable
      |
      --JTableNested
Direct descendents
Class Description
 class TagsTableTag Tags table
 class JTableAsset Table class supporting modified pre-order tree traversal behavior.
 class JTableCategory Category table
 class JTableMenu Menu table
Variable Summary
 string $alias
 integer $level
 integer $lft
 integer $parent_id
 integer $rgt
 array $_cache
 integer $_debug
 string $_location
 integer $_location_id
Method Summary
 boolean check ()
 void debug (integer $level)
 boolean delete ([integer $pk = null], [boolean $children = true])
 mixed getPath ([integer $pk = null], [boolean $diagnostic = false])
 mixed getRootId ()
 mixed getTree ([integer $pk = null], [boolean $diagnostic = false])
 boolean isLeaf ([integer $pk = null])
 mixed move (integer $delta, [string $where = ''])
 boolean moveByReference (integer $referenceId, [string $position = 'after'], [integer $pk = null])
 boolean orderDown (integer $pk)
 boolean orderUp (integer $pk)
 boolean publish ([mixed $pks = null], [integer $state = 1], [integer $userId = 0])
 integer rebuild ([integer $parentId = null], [integer $leftId = 0], [integer $level = 0], [string $path = ''])
 boolean rebuildPath ([integer $pk = null])
 integer saveorder ([array $idArray = null], [array $lft_array = null])
 void setLocation (integer $referenceId, [string $position = 'after'])
 boolean store ([boolean $updateNulls = false])
 mixed _getNode (integer $id, [string $key = null])
 mixed _getTreeRepositionData (object $referenceNode, integer $nodeWidth, [string $position = 'before'])
 void _logtable ([boolean $showData = true], [boolean $showQuery = true])
 boolean _runQuery (mixed $query, string $errorMessage)
Variables
string $alias (line 64)

Object property holding the alias of this node used to constuct the full text path, forward-slash delimited.

  • since: 11.1
  • access: public
integer $level (line 37)

Object property holding the depth level of the node in the tree.

  • since: 11.1
  • access: public
integer $lft (line 46)

Object property holding the left value of the node for managing its placement in the nested sets tree.

  • since: 11.1
  • access: public
integer $parent_id (line 29)

Object property holding the primary key of the parent node. Provides adjacency list data for nodes.

  • since: 11.1
  • access: public
integer $rgt (line 55)

Object property holding the right value of the node for managing its placement in the nested sets tree.

  • since: 11.1
  • access: public
array $_cache = array() (line 91)

An array to cache values in recursive processes.

  • since: 11.1
  • access: protected
integer $_debug = 0 (line 99)

Debug level

  • since: 11.1
  • access: protected
string $_location (line 73)

Object property to hold the location type to use when storing the row.

Possible values are: ['before', 'after', 'first-child', 'last-child'].

  • since: 11.1
  • access: protected
integer $_location_id (line 83)

Object property to hold the primary key of the location reference node to use when storing the row. A combination of location type and reference node describes where to store the current node in the tree.

  • since: 11.1
  • access: protected

Inherited Variables

Inherited from JTable

JTable::$_autoincrement
JTable::$_db
JTable::$_locked
JTable::$_observers
JTable::$_rules
JTable::$_tbl
JTable::$_tbl_key
JTable::$_tbl_keys
JTable::$_trackAssets

Inherited from JObject

JObject::$_errors
Methods
check (line 663)

Checks that the object is valid and able to be stored.

This method checks that the parent_id is non-zero and exists in the database. Note that the root node (parent_id = 0) cannot be manipulated with this class.

  • return: True if all checks pass.
  • throws: Exception
  • since: 11.1
  • throws: RuntimeException on database error.
  • throws: UnexpectedValueException
  • access: public
boolean check ()

Redefinition of:
JTable::check()
Method to perform sanity checks on the JTable instance properties to ensure they are safe to store in the database. Child classes should override this method to make sure the data they are storing in the database is safe and as expected before storage.

Redefined in descendants as:
debug (line 110)

Sets the debug level on or off

  • since: 11.1
  • access: public
void debug (integer $level)
  • integer $level:
    1. = off, 1 = on
delete (line 516)

Method to delete a node and, optionally, its child nodes from the table.

  • return: True on success.
  • since: 11.1
  • access: public
boolean delete ([integer $pk = null], [boolean $children = true])
  • integer $pk: The primary key of the node to delete.
  • boolean $children: True to delete child nodes, false to move them up a level.

Redefinition of:
JTable::delete()
Method to delete a row from the database table by primary key value.

Redefined in descendants as:
getPath (line 126)

Method to get an array of nodes from a given node to its root.

  • return: An array of node objects including the start node.
  • since: 11.1
  • throws: RuntimeException on database error
  • access: public
mixed getPath ([integer $pk = null], [boolean $diagnostic = false])
  • integer $pk: Primary key of the node for which to get the path.
  • boolean $diagnostic: Only select diagnostic data for the nested sets.
getRootId (line 1186)

Gets the ID of the root item in the tree

  • return: The primary id of the root row, or false if not found and the internal error is set.
  • since: 11.1
  • access: public
mixed getRootId ()
getTree (line 156)

Method to get a node and all its child nodes.

  • return: Boolean false on failure or array of node objects on success.
  • since: 11.1
  • throws: RuntimeException on database error.
  • access: public
mixed getTree ([integer $pk = null], [boolean $diagnostic = false])
  • integer $pk: Primary key of the node for which to get the tree.
  • boolean $diagnostic: Only select diagnostic data for the nested sets.
isLeaf (line 184)

Method to determine if a node is a leaf node in the tree (has no children).

  • return: True if a leaf node, false if not or null if the node does not exist.
  • since: 11.1
  • throws: RuntimeException on database error.
  • access: public
boolean isLeaf ([integer $pk = null])
  • integer $pk: Primary key of the node to check.
move (line 241)

Method to move a row in the ordering sequence of a group of rows defined by an SQL WHERE clause.

Negative numbers move the row up in the sequence and positive numbers move it down.

mixed move (integer $delta, [string $where = ''])
  • integer $delta: The direction and magnitude to move the row in the ordering sequence.
  • string $where: WHERE clause to use for limiting the selection of rows to compact the ordering values.

Redefinition of:
JTable::move()
Method to move a row in the ordering sequence of a group of rows defined by an SQL WHERE clause.
moveByReference (line 295)

Method to move a node and its children to a new location in the tree.

boolean moveByReference (integer $referenceId, [string $position = 'after'], [integer $pk = null])
  • integer $referenceId: The primary key of the node to reference new location by.
  • string $position: Location type string. ['before', 'after', 'first-child', 'last-child']
  • integer $pk: The primary key of the node to move.
orderDown (line 1103)

Method to move a node one position to the right in the same level.

  • return: True on success.
  • since: 11.1
  • throws: RuntimeException on database error.
  • access: public
boolean orderDown (integer $pk)
  • integer $pk: Primary key of the node to move.
orderUp (line 1020)

Method to move a node one position to the left in the same level.

  • return: True on success.
  • since: 11.1
  • throws: RuntimeException on database error.
  • access: public
boolean orderUp (integer $pk)
  • integer $pk: Primary key of the node to move.
publish (line 890)

Method to set the publishing state for a node or list of nodes in the database

table. The method respects rows checked out by other users and will attempt to checkin rows that it can after adjustments are made. The method will not allow you to set a publishing state higher than any ancestor node and will not allow you to set a publishing state on a node with a checked out child.

boolean publish ([mixed $pks = null], [integer $state = 1], [integer $userId = 0])
  • mixed $pks: An optional array of primary key values to update. If not set the instance property value is used.
  • integer $state: The publishing state. eg. [0 = unpublished, 1 = published]
  • integer $userId: The user id of the user performing the operation.

Redefinition of:
JTable::publish()
Method to set the publishing state for a row or list of rows in the database table. The method respects checked out rows by other users and will attempt to checkin rows that it can after adjustments are made.
rebuild (line 1255)

Method to recursively rebuild the whole nested set tree.

integer rebuild ([integer $parentId = null], [integer $leftId = 0], [integer $level = 0], [string $path = ''])
  • integer $parentId: The root of the tree to rebuild.
  • integer $leftId: The left id to start with in building the tree.
  • integer $level: The level to assign to the current nodes.
  • string $path: The path to the current nodes.
rebuildPath (line 1344)

Method to rebuild the node's path field from the alias values of the nodes from the current node to the root node of the tree.

boolean rebuildPath ([integer $pk = null])
  • integer $pk: Primary key of the node for which to get the path.
saveorder (line 1402)

Method to update order of table rows

  • return: 1 + value of root rgt on success, false on failure.
  • since: 11.1
  • throws: Exception on database error.
  • access: public
integer saveorder ([array $idArray = null], [array $lft_array = null])
  • array $idArray: id numbers of rows to be reordered.
  • array $lft_array: lft values of rows to be reordered.
setLocation (line 215)

Method to set the location of a node in the tree object. This method does not save the new location to the database, but will set it in the object so that when the node is stored it will be stored in the new location.

  • since: 11.1
  • throws: InvalidArgumentException
  • access: public
void setLocation (integer $referenceId, [string $position = 'after'])
  • integer $referenceId: The primary key of the node to reference new location by.
  • string $position: Location type string. ['before', 'after', 'first-child', 'last-child']
store (line 714)

Method to store a node in the database table.

boolean store ([boolean $updateNulls = false])
  • boolean $updateNulls: True to update null values as well.

Redefinition of:
JTable::store()
Method to store a row in the database from the JTable instance properties.

Redefined in descendants as:
_getNode (line 1455)

Method to get nested set properties for a node in the tree.

  • return: Boolean false on failure or node object on success.
  • since: 11.1
  • throws: RuntimeException on database error.
  • access: protected
mixed _getNode (integer $id, [string $key = null])
  • integer $id: Value to look up the node by.
  • string $key: An optional key to look up the node by (parent | left | right). If omitted, the primary key of the table is used.
_getTreeRepositionData (line 1517)

Method to get various data necessary to make room in the tree at a location for a node and its children. The returned data object includes conditions for SQL WHERE clauses for updating left and right id values to make room for the node as well as the new left and right ids for the node.

  • return: Boolean false on failure or data object on success.
  • since: 11.1
  • access: protected
mixed _getTreeRepositionData (object $referenceNode, integer $nodeWidth, [string $position = 'before'])
  • object $referenceNode: A node object with at least a 'lft' and 'rgt' with which to make room in the tree around for a new node.
  • integer $nodeWidth: The width of the node for which to make room in the tree.
  • string $position: The position relative to the reference node where the room should be made.
_logtable (line 1602)

Method to create a log table in the buffer optionally showing the query and/or data.

  • since: 11.1
  • access: protected
void _logtable ([boolean $showData = true], [boolean $showQuery = true])
  • boolean $showData: True to show data
  • boolean $showQuery: True to show query
_runQuery (line 1645)

Runs a query and unlocks the database on an error.

  • return: void
  • since: 11.1
  • throws: Exception on database error.
  • access: protected
boolean _runQuery (mixed $query, string $errorMessage)
  • mixed $query: A string or JDatabaseQuery object.
  • string $errorMessage: Unused.

Inherited Methods

Inherited From JTable

 JTable::__construct()
 JTable::addIncludePath()
 JTable::appendPrimaryKeys()
 JTable::attachObserver()
 JTable::bind()
 JTable::check()
 JTable::checkIn()
 JTable::checkOut()
 JTable::delete()
 JTable::getDbo()
 JTable::getFields()
 JTable::getInstance()
 JTable::getKeyName()
 JTable::getNextOrder()
 JTable::getObserverOfClass()
 JTable::getPrimaryKey()
 JTable::getRules()
 JTable::getTableName()
 JTable::hasPrimaryKey()
 JTable::hit()
 JTable::isCheckedOut()
 JTable::load()
 JTable::move()
 JTable::publish()
 JTable::reorder()
 JTable::reset()
 JTable::save()
 JTable::setDBO()
 JTable::setRules()
 JTable::store()
 JTable::_getAssetName()
 JTable::_getAssetParentId()
 JTable::_getAssetTitle()
 JTable::_lock()
 JTable::_unlock()

Inherited From JObject

 JObject::__construct()
 JObject::def()
 JObject::get()
 JObject::getError()
 JObject::getErrors()
 JObject::getProperties()
 JObject::set()
 JObject::setError()
 JObject::setProperties()
 JObject::__toString()

Documentation generated on Tue, 19 Nov 2013 15:09:22 +0100 by phpDocumentor 1.4.3