class Category extends Nested

Category table

Properties

integer $parent_id Object property holding the primary key of the parent node. Provides adjacency list data for nodes. from Nested
integer $level Object property holding the depth level of the node in the tree. from Nested
integer $lft Object property holding the left value of the node for managing its placement in the nested sets tree. from Nested
integer $rgt Object property holding the right value of the node for managing its placement in the nested sets tree. from Nested
string $alias Object property holding the alias of this node used to constuct the full text path, forward-slash delimited. from Nested

Methods

__construct( JDatabaseDriver $db)

Constructor

void
attachObserver( JObserverInterface $observer)

Implement \JObservableInterface: Adds an observer to this instance.

from Table
JTableObserver|null
getObserverOfClass( string $observerClass)

Gets the instance of the observer of class $observerClass

from Table
mixed
getFields( bool $reload = false)

Get the columns from database table.

from Table
static  Table|boolean
getInstance( string $type, string $prefix = 'JTable', array $config = array())

Static method to get an instance of a Table class if it can be found in the table include paths.

from Table
static  array
addIncludePath( array|string $path = null)

Add a filesystem path where Table should search for table class files.

from Table
void
appendPrimaryKeys( JDatabaseQuery $query, mixed $pk = null)

Method to append the primary keys for this table to a query.

from Table
string
getTableName()

Method to get the database table name for the class.

from Table
mixed
getKeyName( boolean $multiple = false)

Method to get the primary key field name for the table.

from Table
getDbo()

Method to get the \JDatabaseDriver object.

from Table
boolean
setDbo( JDatabaseDriver $db)

Method to set the \JDatabaseDriver object.

from Table
void
setRules( mixed $input)

Method to set rules for the record.

from Table
JAccessRules
getRules()

Method to get the rules for the record.

from Table
void
reset()

Method to reset class properties to the defaults set in the class definition. It will ignore the primary key as well as any private class properties (except $_errors).

from Nested
boolean
bind( array $array, array|string $ignore = '')

Overloaded bind function.

boolean
load( mixed $keys = null, boolean $reset = true)

Method to load a row from the database by primary key and bind the fields to the Table instance properties.

from Table
boolean
check()

Override check function

boolean
store( boolean $updateNulls = false)

Overridden Table::store to set created/modified and user id.

boolean
save( array|object $src, string $orderingFilter = '', array|string $ignore = '')

Method to provide a shortcut to binding, checking and storing a Table instance to the database table.

from Table
boolean
delete( mixed $pk = null, boolean $children = true)

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

from Nested
boolean
checkOut( integer $userId, mixed $pk = null)

Method to check a row out if the necessary properties/fields exist.

from Table
boolean
checkIn( mixed $pk = null)

Method to check a row in if the necessary properties/fields exist.

from Table
boolean
hasPrimaryKey()

Validate that the primary key has been set.

from Table
boolean
hit( mixed $pk = null)

Method to increment the hits for a row if the necessary property/field exists.

from Table
boolean
isCheckedOut( integer $with, integer $against = null)

Method to determine if a row is checked out and therefore uneditable by a user.

from Table
integer
getNextOrder( string $where = '')

Method to get the next ordering value for a group of rows defined by an SQL WHERE clause.

from Table
array
getPrimaryKey( array $keys = array())

Get the primary key values for this table using passed in values as a default.

from Table
mixed
reorder( string $where = '')

Method to compact the ordering values of rows in a group of rows defined by an SQL WHERE clause.

from Table
boolean
move( integer $delta, string $where = '')

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

from Nested
boolean
publish( mixed $pks = null, integer $state = 1, integer $userId)

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.

from Nested
string
getColumnAlias( string $column)

Method to return the real name of a "special" column such as ordering, hits, published etc etc. In this way you are free to follow your db naming convention and use the built in \Joomla functions.

from Table
void
setColumnAlias( string $column, string $columnAlias)

Method to register a column alias for a "special" column.

from Table
void
debug( integer $level)

Sets the debug level on or off

from Nested
mixed
getPath( integer $pk = null, boolean $diagnostic = false)

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

from Nested
mixed
getTree( integer $pk = null, boolean $diagnostic = false)

Method to get a node and all its child nodes.

from Nested
boolean
isLeaf( integer $pk = null)

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

from Nested
void
setLocation( integer $referenceId, string $position = 'after')

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.

from Nested
boolean
moveByReference( integer $referenceId, string $position = 'after', integer $pk = null, boolean $recursiveUpdate = true)

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

from Nested
boolean
orderUp( integer $pk)

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

from Nested
boolean
orderDown( integer $pk)

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

from Nested
mixed
getRootId()

Gets the ID of the root item in the tree

from Nested
integer
rebuild( integer $parentId = null, integer $leftId, integer $level, string $path = '')

Method to recursively rebuild the whole nested set tree.

from Nested
boolean
rebuildPath( integer $pk = null)

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.

from Nested
integer
saveorder( array $idArray = null, array $lft_array = null)

Method to update order of table rows

from Nested

Details

__construct( JDatabaseDriver $db)

Constructor

Parameters

JDatabaseDriver $db \JDatabaseDriver object.

void attachObserver( JObserverInterface $observer)

Implement \JObservableInterface: Adds an observer to this instance.

This method will be called fron the constructor of classes implementing \JObserverInterface which is instanciated by the constructor of $this with \JObserverMapper::attachAllObservers($this)

Parameters

JObserverInterface $observer The observer to attach to $this observable subject

Return Value

void

JTableObserver|null getObserverOfClass( string $observerClass)

Gets the instance of the observer of class $observerClass

Parameters

string $observerClass The observer class-name to return the object of

Return Value

JTableObserver|null

mixed getFields( bool $reload = false)

Get the columns from database table.

Parameters

bool $reload flag to reload cache

Return Value

mixed An array of the field names, or false if an error occurs.

Exceptions

UnexpectedValueException

static Table|boolean getInstance( string $type, string $prefix = 'JTable', array $config = array())

Static method to get an instance of a Table class if it can be found in the table include paths.

To add include paths for searching for Table classes see Table::addIncludePath().

Parameters

string $type The type (name) of the Table class to get an instance of.
string $prefix An optional prefix for the table class name.
array $config An optional array of configuration values for the Table object.

Return Value

Table|boolean A Table object if found or boolean false on failure.

static array addIncludePath( array|string $path = null)

Add a filesystem path where Table should search for table class files.

Parameters

array|string $path A filesystem path or array of filesystem paths to add.

Return Value

array An array of filesystem paths to find Table classes in.

void appendPrimaryKeys( JDatabaseQuery $query, mixed $pk = null)

Method to append the primary keys for this table to a query.

Parameters

JDatabaseQuery $query A query object to append.
mixed $pk Optional primary key parameter.

Return Value

void

string getTableName()

Method to get the database table name for the class.

Return Value

string The name of the database table being modeled.

mixed getKeyName( boolean $multiple = false)

Method to get the primary key field name for the table.

Parameters

boolean $multiple True to return all primary keys (as an array) or false to return just the first one (as a string).

Return Value

mixed Array of primary key field names or string containing the first primary key field.

JDatabaseDriver getDbo()

Method to get the \JDatabaseDriver object.

Return Value

JDatabaseDriver The internal database driver object.

boolean setDbo( JDatabaseDriver $db)

Method to set the \JDatabaseDriver object.

Parameters

JDatabaseDriver $db A \JDatabaseDriver object to be used by the table object.

Return Value

boolean True on success.

void setRules( mixed $input)

Method to set rules for the record.

Parameters

mixed $input A \JAccessRules object, JSON string, or array.

Return Value

void

JAccessRules getRules()

Method to get the rules for the record.

Return Value

JAccessRules object

void reset()

Method to reset class properties to the defaults set in the class definition. It will ignore the primary key as well as any private class properties (except $_errors).

Return Value

void

boolean bind( array $array, array|string $ignore = '')

Overloaded bind function.

Parameters

array $array named array
array|string $ignore An optional array or space separated list of properties to ignore while binding.

Return Value

boolean True on success.

See also

Table::bind()

boolean load( mixed $keys = null, boolean $reset = true)

Method to load a row from the database by primary key and bind the fields to the Table instance properties.

Parameters

mixed $keys An optional primary key value to load the row by, or an array of fields to match. If not set the instance property value is used.
boolean $reset True to reset the default values before loading the new row.

Return Value

boolean True if successful. False if row not found.

Exceptions

InvalidArgumentException
RuntimeException
UnexpectedValueException

boolean check()

Override check function

Return Value

boolean True if the instance is sane and able to be stored in the database.

See also

Table::check()

boolean store( boolean $updateNulls = false)

Overridden Table::store to set created/modified and user id.

Parameters

boolean $updateNulls True to update fields even if they are null.

Return Value

boolean True on success.

boolean save( array|object $src, string $orderingFilter = '', array|string $ignore = '')

Method to provide a shortcut to binding, checking and storing a Table instance to the database table.

The method will check a row in once the data has been stored and if an ordering filter is present will attempt to reorder the table rows based on the filter. The ordering filter is an instance property name. The rows that will be reordered are those whose value matches the Table instance for the property specified.

Parameters

array|object $src An associative array or object to bind to the Table instance.
string $orderingFilter Filter for the order updating
array|string $ignore An optional array or space separated list of properties to ignore while binding.

Return Value

boolean True on success.

boolean delete( mixed $pk = null, boolean $children = true)

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

Parameters

mixed $pk An optional primary key value to delete. If not set the instance property value is used.
boolean $children True to delete child nodes, false to move them up a level.

Return Value

boolean True on success.

boolean checkOut( integer $userId, mixed $pk = null)

Method to check a row out if the necessary properties/fields exist.

To prevent race conditions while editing rows in a database, a row can be checked out if the fields 'checkedout' and 'checkedout_time' are available. While a row is checked out, any attempt to store the row by a user other than the one who checked the row out should be held until the row is checked in again.

Parameters

integer $userId The Id of the user checking out the row.
mixed $pk An optional primary key value to check out. If not set the instance property value is used.

Return Value

boolean True on success.

Exceptions

UnexpectedValueException

boolean checkIn( mixed $pk = null)

Method to check a row in if the necessary properties/fields exist.

Checking a row in will allow other users the ability to edit the row.

Parameters

mixed $pk An optional primary key value to check out. If not set the instance property value is used.

Return Value

boolean True on success.

Exceptions

UnexpectedValueException

boolean hasPrimaryKey()

Validate that the primary key has been set.

Return Value

boolean True if the primary key(s) have been set.

boolean hit( mixed $pk = null)

Method to increment the hits for a row if the necessary property/field exists.

Parameters

mixed $pk An optional primary key value to increment. If not set the instance property value is used.

Return Value

boolean True on success.

Exceptions

UnexpectedValueException

boolean isCheckedOut( integer $with, integer $against = null)

Method to determine if a row is checked out and therefore uneditable by a user.

If the row is checked out by the same user, then it is considered not checked out -- as the user can still edit it.

Parameters

integer $with The user ID to preform the match with, if an item is checked out by this user the function will return false.
integer $against The user ID to perform the match against when the function is used as a static function.

Return Value

boolean True if checked out.

integer getNextOrder( string $where = '')

Method to get the next ordering value for a group of rows defined by an SQL WHERE clause.

This is useful for placing a new item last in a group of items in the table.

Parameters

string $where WHERE clause to use for selecting the MAX(ordering) for the table.

Return Value

integer The next ordering value.

Exceptions

UnexpectedValueException

array getPrimaryKey( array $keys = array())

Get the primary key values for this table using passed in values as a default.

Parameters

array $keys Optional primary key values to use.

Return Value

array An array of primary key names and values.

mixed reorder( string $where = '')

Method to compact the ordering values of rows in a group of rows defined by an SQL WHERE clause.

Parameters

string $where WHERE clause to use for limiting the selection of rows to compact the ordering values.

Return Value

mixed Boolean True on success.

Exceptions

UnexpectedValueException

boolean move( integer $delta, string $where = '')

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.

Parameters

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.

Return Value

boolean True on success.

boolean publish( mixed $pks = null, integer $state = 1, integer $userId)

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.

Parameters

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.

Return Value

boolean True on success; false if $pks is empty.

Exceptions

UnexpectedValueException

string getColumnAlias( string $column)

Method to return the real name of a "special" column such as ordering, hits, published etc etc. In this way you are free to follow your db naming convention and use the built in \Joomla functions.

Parameters

string $column Name of the "special" column (ie ordering, hits)

Return Value

string The string that identify the special

void setColumnAlias( string $column, string $columnAlias)

Method to register a column alias for a "special" column.

Parameters

string $column The "special" column (ie ordering)
string $columnAlias The real column name (ie foo_ordering)

Return Value

void

void debug( integer $level)

Sets the debug level on or off

Parameters

integer $level 0 = off, 1 = on

Return Value

void

mixed getPath( integer $pk = null, boolean $diagnostic = false)

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

Parameters

integer $pk Primary key of the node for which to get the path.
boolean $diagnostic Only select diagnostic data for the nested sets.

Return Value

mixed An array of node objects including the start node.

Exceptions

RuntimeException on database error

mixed getTree( integer $pk = null, boolean $diagnostic = false)

Method to get a node and all its child nodes.

Parameters

integer $pk Primary key of the node for which to get the tree.
boolean $diagnostic Only select diagnostic data for the nested sets.

Return Value

mixed Boolean false on failure or array of node objects on success.

Exceptions

RuntimeException on database error.

boolean isLeaf( integer $pk = null)

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

Parameters

integer $pk Primary key of the node to check.

Return Value

boolean True if a leaf node, false if not or null if the node does not exist.

Exceptions

RuntimeException on database error.

void setLocation( integer $referenceId, string $position = 'after')

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.

Parameters

integer $referenceId The primary key of the node to reference new location by.
string $position Location type string.

Return Value

void

Exceptions

InvalidArgumentException

See also

Nested::$_validLocations

boolean moveByReference( integer $referenceId, string $position = 'after', integer $pk = null, boolean $recursiveUpdate = true)

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

Parameters

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.
boolean $recursiveUpdate Flag indicate that method recursiveUpdatePublishedColumn should be call.

Return Value

boolean True on success.

Exceptions

RuntimeException on database error.

boolean orderUp( integer $pk)

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

Parameters

integer $pk Primary key of the node to move.

Return Value

boolean True on success.

Exceptions

RuntimeException on database error.

boolean orderDown( integer $pk)

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

Parameters

integer $pk Primary key of the node to move.

Return Value

boolean True on success.

Exceptions

RuntimeException on database error.

mixed getRootId()

Gets the ID of the root item in the tree

Return Value

mixed The primary id of the root row, or false if not found and the internal error is set.

integer rebuild( integer $parentId = null, integer $leftId, integer $level, string $path = '')

Method to recursively rebuild the whole nested set tree.

Parameters

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.

Return Value

integer 1 + value of root rgt on success, false on failure

Exceptions

RuntimeException on database error.

boolean rebuildPath( integer $pk = null)

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.

Parameters

integer $pk Primary key of the node for which to get the path.

Return Value

boolean True on success.

integer saveorder( array $idArray = null, array $lft_array = null)

Method to update order of table rows

Parameters

array $idArray id numbers of rows to be reordered.
array $lft_array lft values of rows to be reordered.

Return Value

integer 1 + value of root rgt on success, false on failure.

Exceptions

Exception on database error.