Category

Extends Nested Implements VersionableTableInterface, TaggableTableInterface

Category table

since

1.5

package

Application

Methods

__construct

Class constructor, overridden in descendant classes.

__construct(mixed properties = null) : mixed
inherited
since

1.7.0

Arguments

properties

mixedEither and associative array or another object to set the initial properties of the object.

Response

mixed

__toString

Magic method to convert the object to a string gracefully.

__toString() : string
inherited deprecated
since

1.7.0

deprecated

3.1.4 Classes should provide their own __toString() implementation.

Response

stringThe classname.

_getAssetName

Method to compute the default name of the asset.

_getAssetName() : string
inherited

The default name is in the form table_name.id where id is the value of the primary key of the table.

since

1.7.0

Response

string

_getAssetParentId

Method to get the parent asset under which to register this one.

_getAssetParentId(\Joomla\CMS\Table\Table table = null, int id = null) : int
inherited

By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. An extended class can define a table and ID to lookup. If the asset does not exist it will be created.

since

1.7.0

Arguments

table

\Joomla\CMS\Table\TableA Table object for the asset parent.

id

intId to look up

Response

int

_getAssetTitle

Method to return the title to use for the asset table.

_getAssetTitle() : string
inherited

In tracking the assets a title is kept for each asset so that there is some context available in a unified access manager. Usually this would just return $this->title or $this->name or whatever is being used for the primary name of the row. If this method is not overridden, the asset name is used.

since

1.7.0

Response

stringThe string to use as the title in the asset table.

_getNode

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

_getNode(int id, string key = null) : mixed
inherited
since

1.7.0

throws

\RuntimeExceptionon database error.

Arguments

id

intValue to look up the node by.

key

stringAn optional key to look up the node by (parent | left | right). If omitted, the primary key of the table is used.

Response

mixedBoolean false on failure or node object on success.

_getTreeRepositionData

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.

_getTreeRepositionData(object referenceNode, int nodeWidth, string position = 'before') : mixed
inherited
since

1.7.0

Arguments

referenceNode

objectA node object with at least a 'lft' and 'rgt' with which to make room in the tree around for a new node.

nodeWidth

intThe width of the node for which to make room in the tree.

position

stringThe position relative to the reference node where the room should be made.

Response

mixedBoolean false on failure or data object on success.

_lock

Method to lock the database table for writing.

_lock() : bool
inherited
since

1.7.0

throws

\RuntimeException

Response

boolTrue on success.

_logtable

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

_logtable(bool showData = true, bool showQuery = true) : void
inherited
since

1.7.0

Arguments

showData

boolTrue to show data

showQuery

boolTrue to show query

_runQuery

Runs a query and unlocks the database on an error.

_runQuery(mixed query, string errorMessage) : void
inherited
note

Since 3.0.0 this method returns void and will rethrow the database exception.

since

1.7.0

throws

\Exceptionon database error.

Arguments

query

mixedA string or DatabaseQuery object.

errorMessage

stringUnused.

_unlock

Method to unlock the database table for writing.

_unlock() : bool
inherited
since

1.7.0

Response

boolTrue on success.

addIncludePath

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

addIncludePath(array|string path = null) : array
inherited static deprecated
since

1.7.0

deprecated

5.0 Should not be used anymore as tables are loaded through the MvcFactory

Arguments

path

array|stringA filesystem path or array of filesystem paths to add.

Response

arrayAn array of filesystem paths to find Table classes in.

appendPrimaryKeys

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

appendPrimaryKeys(\Joomla\Database\DatabaseQuery query, mixed pk = null) : void
inherited
since

3.1.4

Arguments

query

\Joomla\Database\DatabaseQueryA query object to append.

pk

mixedOptional primary key parameter.

bind

Method to bind an associative array or object to the Table instance.This method only binds properties that are publicly accessible and optionally takes an array of properties to ignore when binding.

bind(array|object src, array|string ignore = array()) : bool
inherited
since

1.7.0

throws

\InvalidArgumentException

Arguments

src

array|objectAn associative array or object to bind to the Table instance.

ignore

array|stringAn optional array or space separated list of properties to ignore while binding.

Response

boolTrue on success.

check

Method to perform sanity checks on the Table instance properties to ensure they are safe to store in the database.

check() : bool
inherited

Child classes should override this method to make sure the data they are storing in the database is safe and as expected before storage.

since

1.7.0

Response

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

checkIn

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

checkIn(mixed pk = null) : bool
inherited

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

since

1.7.0

throws

\UnexpectedValueException

Arguments

pk

mixedAn optional primary key value to check out. If not set the instance property value is used.

Response

boolTrue on success.

checkOut

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

checkOut(int userId, mixed pk = null) : bool
inherited

To prevent race conditions while editing rows in a database, a row can be checked out if the fields 'checked_out' and 'checked_out_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.

since

1.7.0

throws

\UnexpectedValueException

Arguments

userId

intThe Id of the user checking out the row.

pk

mixedAn optional primary key value to check out. If not set the instance property value is used.

Response

boolTrue on success.

clearTagsHelper

Clears the tags helper

clearTagsHelper() : void
inherited
since

4.0.0

debug

Sets the debug level on or off

debug(int level) : void
inherited
since

1.7.0

Arguments

level

int0 = off, 1 = on

def

Sets a default value if not already assigned

def(string property, mixed default = null) : mixed
inherited
since

1.7.0

Arguments

property

stringThe name of the property.

default

mixedThe default value.

Response

mixed

delete

Method to delete a row from the database table by primary key value.

delete(mixed pk = null) : bool
inherited
since

1.7.0

throws

\UnexpectedValueException

Arguments

pk

mixedAn optional primary key value to delete. If not set the instance property value is used.

Response

boolTrue on success.

get

Returns a property of the object or the default value if the property is not set.

get(string property, mixed default = null) : mixed
inherited
since

1.7.0

see CMSObject::getProperties()

Arguments

property

stringThe name of the property.

default

mixedThe default value.

Response

mixedThe value of the property.

getColumnAlias

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.

getColumnAlias(string column) : string
inherited
since

3.4

Arguments

column

stringName of the "special" column (ie ordering, hits)

Response

stringThe string that identify the special

getDbo

Method to get the DatabaseDriver object.

getDbo() : \Joomla\Database\DatabaseDriver
inherited
since

1.7.0

Response

\Joomla\Database\DatabaseDriverThe internal database driver object.

getError

Get the most recent error message.

getError(int i = null, bool toString = true) : string
inherited deprecated
since

1.7.0

deprecated

3.1.4 JError has been deprecated

Arguments

i

intOption error index.

toString

boolIndicates if Exception objects should return their error message.

Response

stringError message

getErrors

Return all errors, if any.

getErrors() : array
inherited deprecated
since

1.7.0

deprecated

3.1.4 JError has been deprecated

Response

arrayArray of error messages.

getFields

Get the columns from database table.

getFields(bool reload = false) : mixed
inherited
since

1.7.0

throws

\UnexpectedValueException

Arguments

reload

boolflag to reload cache

Response

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

getId

Returns the identity (primary key) value of this record

getId() : mixed
inherited
since

4.0.0

Response

mixed

getInstance

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

getInstance(string type, string prefix = 'JTable', array config = array()) : \Joomla\CMS\Table\Table|bool
inherited static deprecated

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

since

1.7.0

deprecated

5.0 Use the MvcFactory instead

Arguments

type

stringThe type (name) of the Table class to get an instance of.

prefix

stringAn optional prefix for the table class name.

config

arrayAn optional array of configuration values for the Table object.

Response

\Joomla\CMS\Table\Table|boolA Table object if found or boolean false on failure.

getKeyName

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

getKeyName(bool multiple = false) : mixed
inherited
since

1.7.0

Arguments

multiple

boolTrue to return all primary keys (as an array) or false to return just the first one (as a string).

Response

mixedArray of primary key field names or string containing the first primary key field.

getNextOrder

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

getNextOrder(string where = '') : int
inherited

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

since

1.7.0

throws

\UnexpectedValueException

Arguments

where

stringWHERE clause to use for selecting the MAX(ordering) for the table.

Response

intThe next ordering value.

getPath

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

getPath(int pk = null, bool diagnostic = false) : mixed
inherited
since

1.7.0

throws

\RuntimeExceptionon database error

Arguments

pk

intPrimary key of the node for which to get the path.

diagnostic

boolOnly select diagnostic data for the nested sets.

Response

mixedAn array of node objects including the start node.

getPrimaryKey

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

getPrimaryKey(array keys = array()) : array
inherited
since

3.1.4

Arguments

keys

arrayOptional primary key values to use.

Response

arrayAn array of primary key names and values.

getProperties

Returns an associative array of object properties.

getProperties(bool public = true) : array
inherited
since

1.7.0

see CMSObject::get()

Arguments

public

boolIf true, returns only the public properties.

Response

array

getRootId

Gets the ID of the root item in the tree

getRootId() : mixed
inherited
since

1.7.0

Response

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

getRules

Method to get the rules for the record.

getRules() : \Joomla\CMS\Access\Rules
inherited
since

1.7.0

Response

\Joomla\CMS\Access\Rulesobject

getTableName

Method to get the database table name for the class.

getTableName() : string
inherited
since

1.7.0

Response

stringThe name of the database table being modeled.

getTagsHelper

Get the tags helper

getTagsHelper() : \Joomla\CMS\Helper\TagsHelper
inherited
since

4.0.0

Response

\Joomla\CMS\Helper\TagsHelperThe tags helper object

getTree

Method to get a node and all its child nodes.

getTree(int pk = null, bool diagnostic = false) : mixed
inherited
since

1.7.0

throws

\RuntimeExceptionon database error.

Arguments

pk

intPrimary key of the node for which to get the tree.

diagnostic

boolOnly select diagnostic data for the nested sets.

Response

mixedBoolean false on failure or array of node objects on success.

getTypeAlias

Get the type alias for the history table

getTypeAlias() : string
since

4.0.0

Response

stringThe alias as described above

hasField

Check if the record has a property (applying a column alias if it exists)

hasField(string key) : bool
inherited
since

3.9.11

Arguments

key

stringkey to be checked

Response

bool

hasPrimaryKey

Validate that the primary key has been set.

hasPrimaryKey() : bool
inherited
since

3.1.4

Response

boolTrue if the primary key(s) have been set.

hit

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

hit(mixed pk = null) : bool
inherited
since

1.7.0

throws

\UnexpectedValueException

Arguments

pk

mixedAn optional primary key value to increment. If not set the instance property value is used.

Response

boolTrue on success.

isCheckedOut

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

isCheckedOut(int with, int against = null) : bool
inherited

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

since

1.7.0

Arguments

with

intThe user ID to preform the match with, if an item is checked out by this user the function will return false.

against

intThe user ID to perform the match against when the function is used as a static function.

Response

boolTrue if checked out.

isLeaf

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

isLeaf(int pk = null) : bool
inherited
note

Since 3.0.0 this method returns null if the node does not exist.

since

1.7.0

throws

\RuntimeExceptionon database error.

Arguments

pk

intPrimary key of the node to check.

Response

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

load

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

load(mixed keys = null, bool reset = true) : bool
inherited
since

1.7.0

throws

\InvalidArgumentException

\RuntimeException

\UnexpectedValueException

Arguments

keys

mixedAn 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.

reset

boolTrue to reset the default values before loading the new row.

Response

boolTrue if successful. False if row not found.

move

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

move(int delta, string where = '') : bool
inherited

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

since

1.7.0

throws

\UnexpectedValueException

Arguments

delta

intThe direction and magnitude to move the row in the ordering sequence.

where

stringWHERE clause to use for limiting the selection of rows to compact the ordering values.

Response

boolTrue on success.

moveByReference

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

moveByReference(int referenceId, string position = 'after', int pk = null, bool recursiveUpdate = true) : bool
inherited
since

1.7.0

throws

\RuntimeExceptionon database error.

Arguments

referenceId

intThe primary key of the node to reference new location by.

position

stringLocation type string. ['before', 'after', 'first-child', 'last-child']

pk

intThe primary key of the node to move.

recursiveUpdate

boolFlag indicate that method recursiveUpdatePublishedColumn should be call.

Response

boolTrue on success.

orderDown

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

orderDown(int pk) : bool
inherited
since

1.7.0

throws

\RuntimeExceptionon database error.

Arguments

pk

intPrimary key of the node to move.

Response

boolTrue on success.

orderUp

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

orderUp(int pk) : bool
inherited
since

1.7.0

throws

\RuntimeExceptionon database error.

Arguments

pk

intPrimary key of the node to move.

Response

boolTrue on success.

publish

Method to set the publishing state for a row or list of rows in the database table.

publish(mixed pks = null, int state = 1, int userId) : bool
inherited

The method respects checked out rows by other users and will attempt to checkin rows that it can after adjustments are made.

since

1.7.0

Arguments

pks

mixedAn optional array of primary key values to update. If not set the instance property value is used.

state

intThe publishing state. eg. [0 = unpublished, 1 = published]

userId

intThe user ID of the user performing the operation.

Response

boolTrue on success; false if $pks is empty.

rebuild

Method to recursively rebuild the whole nested set tree.

rebuild(int parentId = null, int leftId, int level, string path = '') : int
inherited
since

1.7.0

throws

\RuntimeExceptionon database error.

Arguments

parentId

intThe root of the tree to rebuild.

leftId

intThe left id to start with in building the tree.

level

intThe level to assign to the current nodes.

path

stringThe path to the current nodes.

Response

int1 + value of root rgt on success, false on failure

rebuildPath

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.

rebuildPath(int pk = null) : bool
inherited
since

1.7.0

Arguments

pk

intPrimary key of the node for which to get the path.

Response

boolTrue on success.

recursiveUpdatePublishedColumn

Method to recursive update published column for children rows.

recursiveUpdatePublishedColumn(int pk, int newState = null) : bool
inherited
since

3.7.0

throws

\RuntimeExceptionon database error.

Arguments

pk

intId number of row which published column was changed.

newState

intAn optional value for published column of row identified by $pk.

Response

boolTrue on success.

reorder

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

reorder(string where = '') : mixed
inherited
since

1.7.0

throws

\UnexpectedValueException

Arguments

where

stringWHERE clause to use for limiting the selection of rows to compact the ordering values.

Response

mixedBoolean True on success.

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).

reset() : void
inherited
since

1.7.0

save

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

save(array|object src, string orderingFilter = '', array|string ignore = '') : bool
inherited

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.

since

1.7.0

Arguments

src

array|objectAn associative array or object to bind to the Table instance.

orderingFilter

stringFilter for the order updating

ignore

array|stringAn optional array or space separated list of properties to ignore while binding.

Response

boolTrue on success.

saveorder

Method to update order of table rows

saveorder(array idArray = null, array lftArray = null) : int|bool
inherited
since

1.7.0

throws

\Exceptionon database error.

Arguments

idArray

arrayid numbers of rows to be reordered.

lftArray

arraylft values of rows to be reordered.

Response

int|bool1 + value of root rgt on success, false on failure.

set

Modifies a property of the object, creating it if it does not already exist.

set(string property, mixed value = null) : mixed
inherited
since

1.7.0

Arguments

property

stringThe name of the property.

value

mixedThe value of the property to set.

Response

mixedPrevious value of the property.

setColumnAlias

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

setColumnAlias(string column, string columnAlias) : void
inherited
since

3.4

Arguments

column

stringThe "special" column (ie ordering)

columnAlias

stringThe real column name (ie foo_ordering)

setDbo

Method to set the DatabaseDriver object.

setDbo(\Joomla\Database\DatabaseDriver db) : bool
inherited
since

1.7.0

Arguments

db

\Joomla\Database\DatabaseDriverA DatabaseDriver object to be used by the table object.

Response

boolTrue on success.

setError

Add an error message.

setError(string error) : void
inherited deprecated
since

1.7.0

deprecated

3.1.4 JError has been deprecated

Arguments

error

stringError message.

setLocation

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.

setLocation(int referenceId, string position = 'after') : void
inherited
note

Since 3.0.0 this method returns void and throws an \InvalidArgumentException when an invalid position is passed.

see Nested::$_validLocations
since

1.7.0

throws

\InvalidArgumentException

Arguments

referenceId

intThe primary key of the node to reference new location by.

position

stringLocation type string.

setProperties

Set the object properties based on a named array/hash.

setProperties(mixed properties) : bool
inherited
since

1.7.0

see CMSObject::set()

Arguments

properties

mixedEither an associative array or another object.

Response

bool

setRules

Method to set rules for the record.

setRules(mixed input) : void
inherited
since

1.7.0

Arguments

input

mixedA Rules object, JSON string, or array.

setTagsHelper

Set the tags helper

setTagsHelper(\Joomla\CMS\Helper\TagsHelper tagsHelper) : void
inherited
since

4.0.0

Arguments

tagsHelper

\Joomla\CMS\Helper\TagsHelperThe tags helper to be set

store

Method to store a row in the database from the Table instance properties.

store(bool updateNulls = false) : bool
inherited

If a primary key value is set the row with that primary key value will be updated with the instance property values. If no primary key value is set a new row will be inserted into the database with the properties from the Table instance.

since

1.7.0

Arguments

updateNulls

boolTrue to update fields even if they are null.

Response

boolTrue on success.

Properties

_supportNullValue

Indicates that columns fully support the NULL value in the database

inherited
since

3.10.0

Type(s)

bool

tagsHelper

The tags helper property

inherited
since

4.0.0

note

The tags helper property is set to public for backwards compatibility for Joomla 4.0. It will be made a protected property in Joomla 5.0

Type(s)

TagsHelper

parent_id

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

inherited
since

1.7.0

Type(s)

int

level

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

inherited
since

1.7.0

Type(s)

int

lft

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

inherited
since

1.7.0

Type(s)

int

rgt

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

inherited
since

1.7.0

Type(s)

int

alias

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

inherited
since

1.7.0

Type(s)

string

_location

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

inherited
since

1.7.0

see Nested::$_validLocations

Type(s)

string

_location_id

Object property to hold the primary key of the location reference node to use when storing the row.

inherited

A combination of location type and reference node describes where to store the current node in the tree.

since

1.7.0

Type(s)

int

_cache

An array to cache values in recursive processes.

inherited
since

1.7.0

Type(s)

array

_debug

Debug level

inherited
since

1.7.0

Type(s)

int

root_id

Cache for the root ID

inherited static
since

3.3

Type(s)

int

_validLocations

Array declaring the valid location values for moving a node

inherited
since

3.7.0

Type(s)

array

_includePaths

Include paths for searching for Table classes.

inherited static
since

3.0.0

Type(s)

array

tableFields

Table fields cache

inherited static
since

3.10.4

Type(s)

array

_tbl

Name of the database table to model.

inherited
since

1.7.0

Type(s)

string

_tbl_key

Name of the primary key field in the table.

inherited
since

1.7.0

Type(s)

string

_tbl_keys

Name of the primary key fields in the table.

inherited
since

3.0.1

Type(s)

array

_db

DatabaseDriver object.

inherited
since

1.7.0

Type(s)

\Joomla\Database\DatabaseDriver

_trackAssets

Should rows be tracked as ACL assets?

inherited
since

1.7.0

Type(s)

bool

_rules

The rules associated with this record.

inherited
since

1.7.0

Type(s)

Rules

_locked

Indicator that the tables have been locked.

inherited
since

1.7.0

Type(s)

bool

_autoincrement

Indicates that the primary keys autoincrement.

inherited
since

3.1.4

Type(s)

bool

_columnAlias

Array with alias for "special" columns such as ordering, hits etc etc

inherited
since

3.4.0

Type(s)

array

_jsonEncode

An array of key names to be json encoded in the bind function

inherited
since

3.3

Type(s)

array

typeAlias

The UCM type alias. Used for tags, content versioning etc. Leave blank to effectively disable these features.

inherited
since

4.0.0

Type(s)

string

_errors

An array of error messages or Exception objects.

inherited deprecated
since

1.7.0

deprecated

3.1.4 JError has been deprecated

Type(s)

array