Back to Joomla project (class list)

Class Table - list of methods

Abstract Table class
Parent class to all tables.

Extends

Extends

Direct known subclasses

Package: Joomla\CMS\Table
Copyright: (C) 2005 Open Source Matters, Inc.
License: GNU General Public License version 2 or later; see LICENSE.txt
Located at: Joomla/Table/Table.php
Project: Joomla

Method Summary

public
(mixed $table, mixed $key, \Joomla\Database\DatabaseDriver $db, \Joomla\Event\DispatcherInterface $dispatcher = null)

Object constructor to set table and key fields. In most cases this will be overridden by child classes to explicitly set the table and key fields for a particular database table.
Parameters
  • string $table Name of the table to model.
  • mixed $key Name of the primary key field in the table or array of field names that compose the primary key.
  • \Joomla\Database\DatabaseDriver $db DatabaseDriver object.
  • \Joomla\Event\DispatcherInterface $dispatcher Event dispatcher for this table
Since
  • 1.7.0
Show source code of this method: __construct Source Code

public mixed
(mixed $reload = false)

Get the columns from database table.
Parameters
  • bool $reload flag to reload cache
Returns
  • mixed An array of the field names, or false if an error occurs.
Since
  • 1.7.0
-
  • \UnexpectedValueException
Show source code of this method: getFields Source Code

public static \Joomla\CMS\Table\Table|bool
(mixed $type, mixed $prefix = 'JTable', mixed $config = array())

Static method to get an instance of a Table class if it can be found in the table include paths.
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.
Returns
  • \Joomla\CMS\Table\Table|bool A Table object if found or boolean false on failure.
Since
  • 1.7.0
Deprecated
  • 5.0
Show source code of this method: getInstance Source Code

public static array
(mixed $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.
Returns
  • array An array of filesystem paths to find Table classes in.
Since
  • 1.7.0
Deprecated
  • 5.0
Show source code of this method: addIncludePath Source Code

protected string
()

Method to compute the default name of the asset.
Returns
  • string
Since
  • 1.7.0
Show source code of this method: _getAssetName Source Code

protected string
()

Method to return the title to use for the asset table.
Returns
  • string The string to use as the title in the asset table.
Since
  • 1.7.0
Show source code of this method: _getAssetTitle Source Code

protected int
(\Joomla\CMS\Table\Table $table = null, mixed $id = null)

Method to get the parent asset under which to register this one.
Parameters
  • \Joomla\CMS\Table\Table $table A Table object for the asset parent.
  • int $id Id to look up
Returns
  • int
Since
  • 1.7.0
Show source code of this method: _getAssetParentId Source Code

public void
(mixed $query, mixed $pk = null)

Method to append the primary keys for this table to a query.
Parameters
  • \Joomla\Database\DatabaseQuery $query A query object to append.
  • mixed $pk Optional primary key parameter.
Returns
  • void
Since
  • 3.1.4
Show source code of this method: appendPrimaryKeys Source Code

public string
()

Method to get the database table name for the class.
Returns
  • string The name of the database table being modeled.
Since
  • 1.7.0
Show source code of this method: getTableName Source Code

public mixed
(mixed $multiple = false)

Method to get the primary key field name for the table.
Parameters
  • bool $multiple True to return all primary keys (as an array) or false to return just the first one (as a string).
Returns
  • mixed Array of primary key field names or string containing the first primary key field.
Since
  • 1.7.0
Show source code of this method: getKeyName Source Code

public mixed
()

Returns the identity (primary key) value of this record
Returns
  • mixed
Since
  • 4.0.0
Show source code of this method: getId Source Code

public \Joomla\Database\DatabaseDriver
()

Method to get the DatabaseDriver object.
Returns
  • \Joomla\Database\DatabaseDriver The internal database driver object.
Since
  • 1.7.0
Show source code of this method: getDbo Source Code

public bool
(\Joomla\Database\DatabaseDriver $db)

Method to set the DatabaseDriver object.
Parameters
  • \Joomla\Database\DatabaseDriver $db A DatabaseDriver object to be used by the table object.
Returns
  • bool True on success.
Since
  • 1.7.0
Show source code of this method: setDbo Source Code

public void
(mixed $input)

Method to set rules for the record.
Parameters
  • mixed $input A Rules object, JSON string, or array.
Returns
  • void
Since
  • 1.7.0
Show source code of this method: setRules Source Code

public \Joomla\CMS\Access\Rules
()

Method to get the rules for the record.
Returns
  • \Joomla\CMS\Access\Rules object
Since
  • 1.7.0
Show source code of this method: getRules Source Code

public void
()

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).
Returns
  • void
Since
  • 1.7.0
Show source code of this method: reset Source Code

public bool
(mixed $src, mixed $ignore = array())

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.
Parameters
  • array|object $src An associative array or object to bind to the Table instance.
  • array|string $ignore An optional array or space separated list of properties to ignore while binding.
Returns
  • bool True on success.
Since
  • 1.7.0
-
  • \InvalidArgumentException
Show source code of this method: bind Source Code

public bool
(mixed $keys = null, mixed $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.
  • bool $reset True to reset the default values before loading the new row.
Returns
  • bool True if successful. False if row not found.
Since
  • 1.7.0
-
  • \InvalidArgumentException
  • \RuntimeException
  • \UnexpectedValueException
Show source code of this method: load Source Code

public bool
()

Method to perform sanity checks on the Table instance properties to ensure they are safe to store in the database.
Returns
  • bool True if the instance is sane and able to be stored in the database.
Since
  • 1.7.0
Show source code of this method: check Source Code

public bool
(mixed $updateNulls = false)

Method to store a row in the database from the Table instance properties.
Parameters
  • bool $updateNulls True to update fields even if they are null.
Returns
  • bool True on success.
Since
  • 1.7.0
Show source code of this method: store Source Code

public bool
(mixed $src, mixed $orderingFilter = '', mixed $ignore = '')

Method to provide a shortcut to binding, checking and storing a Table instance to the database table.
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.
Returns
  • bool True on success.
Since
  • 1.7.0
Show source code of this method: save Source Code

public bool
(mixed $pk = null)

Method to delete a row from the database table by primary key value.
Parameters
  • mixed $pk An optional primary key value to delete. If not set the instance property value is used.
Returns
  • bool True on success.
Since
  • 1.7.0
-
  • \UnexpectedValueException
Show source code of this method: delete Source Code

public bool
(mixed $userId, mixed $pk = null)

Method to check a row out if the necessary properties/fields exist.
Parameters
  • int $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.
Returns
  • bool True on success.
Since
  • 1.7.0
-
  • \UnexpectedValueException
Show source code of this method: checkOut Source Code

public bool
(mixed $pk = null)

Method to check a row in if the necessary properties/fields exist.
Parameters
  • mixed $pk An optional primary key value to check out. If not set the instance property value is used.
Returns
  • bool True on success.
Since
  • 1.7.0
-
  • \UnexpectedValueException
Show source code of this method: checkIn Source Code

public bool
()

Validate that the primary key has been set.
Returns
  • bool True if the primary key(s) have been set.
Since
  • 3.1.4
Show source code of this method: hasPrimaryKey Source Code

public bool
(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.
Returns
  • bool True on success.
Since
  • 1.7.0
-
  • \UnexpectedValueException
Show source code of this method: hit Source Code

public bool
(mixed $with = 0, mixed $against = null)

Method to determine if a row is checked out and therefore uneditable by a user.
Parameters
  • int $with The user ID to preform the match with, if an item is checked out by this user the function will return false.
  • int $against The user ID to perform the match against when the function is used as a static function.
Returns
  • bool True if checked out.
Since
  • 1.7.0
Show source code of this method: isCheckedOut Source Code

public int
(mixed $where = '')

Method to get the next ordering value for a group of rows defined by an SQL WHERE clause.
Parameters
  • string $where WHERE clause to use for selecting the MAX(ordering) for the table.
Returns
  • int The next ordering value.
Since
  • 1.7.0
-
  • \UnexpectedValueException
Show source code of this method: getNextOrder Source Code

public array
(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.
Returns
  • array An array of primary key names and values.
Since
  • 3.1.4
Show source code of this method: getPrimaryKey Source Code

public mixed
(mixed $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.
Returns
  • mixed Boolean True on success.
Since
  • 1.7.0
-
  • \UnexpectedValueException
Show source code of this method: reorder Source Code

public bool
(mixed $delta, mixed $where = '')

Method to move a row in the ordering sequence of a group of rows defined by an SQL WHERE clause.
Parameters
  • int $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.
Returns
  • bool True on success.
Since
  • 1.7.0
-
  • \UnexpectedValueException
Show source code of this method: move Source Code

public bool
(mixed $pks = null, mixed $state = 1, mixed $userId = 0)

Method to set the publishing state for a row or list of rows in the database table.
Parameters
  • mixed $pks An optional array of primary key values to update. If not set the instance property value is used.
  • int $state The publishing state. eg. [0 = unpublished, 1 = published]
  • int $userId The user ID of the user performing the operation.
Returns
  • bool True on success; false if $pks is empty.
Since
  • 1.7.0
Show source code of this method: publish Source Code

protected bool
()

Method to lock the database table for writing.
Returns
  • bool True on success.
Since
  • 1.7.0
-
  • \RuntimeException
Show source code of this method: _lock Source Code

public string
(mixed $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)
Returns
  • string The string that identify the special
Since
  • 3.4
Show source code of this method: getColumnAlias Source Code

public void
(mixed $column, mixed $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)
Returns
  • void
Since
  • 3.4
Show source code of this method: setColumnAlias Source Code

protected bool
()

Method to unlock the database table for writing.
Returns
  • bool True on success.
Since
  • 1.7.0
Show source code of this method: _unlock Source Code

public bool
(mixed $key)

Check if the record has a property (applying a column alias if it exists)
Parameters
  • string $key key to be checked
Returns
  • bool
Since
  • 3.9.11
Show source code of this method: hasField Source Code

Properties Summary

private static array
$_includePaths
Include paths for searching for Table classes.
Since
  • 3.0.0
private static array
$tableFields
Table fields cache
Since
  • 3.10.4
protected string
$_tbl
Name of the database table to model.
Since
  • 1.7.0
protected string
$_tbl_key
Name of the primary key field in the table.
Since
  • 1.7.0
protected array
$_tbl_keys
Name of the primary key fields in the table.
Since
  • 3.0.1
protected \Joomla\Database\DatabaseDriver
$_db
DatabaseDriver object.
Since
  • 1.7.0
protected bool
$_trackAssets
Should rows be tracked as ACL assets?
Since
  • 1.7.0
protected \Joomla\CMS\Access\Rules
$_rules
The rules associated with this record.
Since
  • 1.7.0
protected bool
$_locked
Indicator that the tables have been locked.
Since
  • 1.7.0
protected bool
$_autoincrement
Indicates that the primary keys autoincrement.
Since
  • 3.1.4
protected array
$_columnAlias
Array with alias for "special" columns such as ordering, hits etc etc
Since
  • 3.4.0
protected array
$_jsonEncode
An array of key names to be json encoded in the bind function
Since
  • 3.3
protected bool
$_supportNullValue
Indicates that columns fully support the NULL value in the database
Since
  • 3.10.0
public string
$typeAlias
The UCM type alias. Used for tags, content versioning etc. Leave blank to effectively disable these features.
Since
  • 4.0.0

Tags Summary

Since
1.7.0