ContentType
Extends \Joomla\CMS\Table\TableTags table
Parent class to all tables.
since |
3.1 |
---|
Methods
__construct
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.
__construct(string $table, mixed $key, \JDatabaseDriver $db)
since |
1.7.0 |
---|
Arguments
- $table
string
Name of the table to model.- $key
mixed
Name of the primary key field in the table or array of field names that compose the primary key.- $db
\JDatabaseDriver
\JDatabaseDriver object.
_getAssetName
Method to compute the default name of the asset.
_getAssetName() : string
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, integer $id = null) : integer
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\Table
A Table object for the asset parent.- $id
integer
Id to look up
Response
integer
_getAssetTitle
Method to return the title to use for the asset table.
_getAssetTitle() : string
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
string
The string to use as the title in the asset table.
_lock
Method to lock the database table for writing.
_lock() : boolean
since |
1.7.0 |
---|---|
throws |
|
Response
boolean
True on success.
_unlock
Method to unlock the database table for writing.
_unlock() : boolean
since |
1.7.0 |
---|
Response
boolean
True on success.
addIncludePath
Add a filesystem path where Table should search for table class files.
addIncludePath(array|string $path = null) : array
since |
1.7.0 |
---|
Arguments
- $path
array|string
A filesystem path or array of filesystem paths to add.
Response
array
An array of filesystem paths to find Table classes in.
appendPrimaryKeys
Method to append the primary keys for this table to a query.
appendPrimaryKeys(\JDatabaseQuery $query, mixed $pk = null) : void
since |
3.1.4 |
---|
Arguments
- $query
\JDatabaseQuery
A query object to append.- $pk
mixed
Optional primary key parameter.
attachObserver
Implement \JObservableInterface: Adds an observer to this instance.
attachObserver(\JObserverInterface|\JTableObserver $observer) : void
This method will be called fron the constructor of classes implementing \JObserverInterface which is instanciated by the constructor of $this with \JObserverMapper::attachAllObservers($this)
since |
3.1.2 |
---|
Arguments
- $observer
\JObserverInterface|\JTableObserver
The observer object
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()) : boolean
since |
1.7.0 |
---|---|
throws |
|
Arguments
- $src
array|object
An associative array or object to bind to the Table instance.- $ignore
array|string
An optional array or space separated list of properties to ignore while binding.
Response
boolean
True on success.
check
Method to perform sanity checks on the Table instance properties to ensure they are safe to store in the database.
check() : boolean
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
boolean
True 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) : boolean
Checking a row in will allow other users the ability to edit the row.
since |
1.7.0 |
---|---|
throws |
|
Arguments
- $pk
mixed
An optional primary key value to check out. If not set the instance property value is used.
Response
boolean
True on success.
checkOut
Method to check a row out if the necessary properties/fields exist.
checkOut(integer $userId, mixed $pk = null) : boolean
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 |
|
Arguments
- $userId
integer
The Id of the user checking out the row.- $pk
mixed
An optional primary key value to check out. If not set the instance property value is used.
Response
boolean
True on success.
delete
Method to delete a row from the database table by primary key value.
delete(mixed $pk = null) : boolean
since |
1.7.0 |
---|---|
throws |
|
Arguments
- $pk
mixed
An optional primary key value to delete. If not set the instance property value is used.
Response
boolean
True on success.
fieldmapExpand
Method to expand the field mapping
fieldmapExpand(boolean $assoc = true) : mixed
since |
3.1 |
---|
Arguments
- $assoc
boolean
True to return an associative array.
Response
mixed
Array or object with field mappings. Defaults to object.
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
since |
3.4 |
---|
Arguments
- $column
string
Name of the "special" column (ie ordering, hits)
Response
string
The string that identify the special
getContentTable
Method to get the Table object for the content type from the table object.
getContentTable() : mixed
since |
3.2 |
---|---|
throws |
|
Response
mixed
Table object on success, otherwise false.
getDbo
Method to get the \JDatabaseDriver object.
getDbo() : \JDatabaseDriver
getFields
Get the columns from database table.
getFields(boolean $reload = false) : mixed
since |
1.7.0 |
---|---|
throws |
|
Arguments
- $reload
boolean
flag to reload cache
Response
mixed
An array of the field names, or false if an error occurs.
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|boolean
To add include paths for searching for Table classes see Table::addIncludePath().
since |
1.7.0 |
---|
Arguments
- $type
string
The type (name) of the Table class to get an instance of.- $prefix
string
An optional prefix for the table class name.- $config
array
An optional array of configuration values for the Table object.
Response
\Joomla\CMS\Table\Table|boolean
A Table object if found or boolean false on failure.
getKeyName
Method to get the primary key field name for the table.
getKeyName(boolean $multiple = false) : mixed
since |
1.7.0 |
---|
Arguments
- $multiple
boolean
True to return all primary keys (as an array) or false to return just the first one (as a string).
Response
mixed
Array 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 = '') : integer
This is useful for placing a new item last in a group of items in the table.
since |
1.7.0 |
---|---|
throws |
|
Arguments
- $where
string
WHERE clause to use for selecting the MAX(ordering) for the table.
Response
integer
The next ordering value.
getObserverOfClass
Gets the instance of the observer of class $observerClass
getObserverOfClass(string $observerClass) : \JTableObserver|null
since |
3.1.2 |
---|
Arguments
- $observerClass
string
The observer class-name to return the object of
Response
\JTableObserver|null
getPrimaryKey
Get the primary key values for this table using passed in values as a default.
getPrimaryKey(array $keys = array()) : array
since |
3.1.4 |
---|
Arguments
- $keys
array
Optional primary key values to use.
Response
array
An array of primary key names and values.
getRules
Method to get the rules for the record.
getRules() : \JAccessRules
since |
1.7.0 |
---|
Response
\JAccessRules
object
getTableName
Method to get the database table name for the class.
getTableName() : string
since |
1.7.0 |
---|
Response
string
The name of the database table being modeled.
getTypeId
Method to get the id given the type alias
getTypeId(string $typeAlias) : mixed
since |
3.2 |
---|
Arguments
- $typeAlias
string
Content type alias (for example, 'com_content.article').
Response
mixed
type_id for this alias if successful, otherwise null.
hasField
Check if the record has a property (applying a column alias if it exists)
hasField(string $key) : boolean
since |
3.9.11 |
---|
Arguments
- $key
string
key to be checked
Response
boolean
hasPrimaryKey
Validate that the primary key has been set.
hasPrimaryKey() : boolean
since |
3.1.4 |
---|
Response
boolean
True 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) : boolean
since |
1.7.0 |
---|---|
throws |
|
Arguments
- $pk
mixed
An optional primary key value to increment. If not set the instance property value is used.
Response
boolean
True on success.
isCheckedOut
Method to determine if a row is checked out and therefore uneditable by a user.
isCheckedOut(integer $with, integer $against = null) : boolean
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
integer
The user ID to preform the match with, if an item is checked out by this user the function will return false.- $against
integer
The user ID to perform the match against when the function is used as a static function.
Response
boolean
True if checked out.
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, boolean $reset = true) : boolean
since |
1.7.0 |
---|---|
throws |
|
Arguments
- $keys
mixed
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.- $reset
boolean
True to reset the default values before loading the new row.
Response
boolean
True 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(integer $delta, string $where = '') : boolean
Negative numbers move the row up in the sequence and positive numbers move it down.
since |
1.7.0 |
---|---|
throws |
|
Arguments
- $delta
integer
The direction and magnitude to move the row in the ordering sequence.- $where
string
WHERE clause to use for limiting the selection of rows to compact the ordering values.
Response
boolean
True on success.
publish
Method to set the publishing state for a row or list of rows in the database table.
publish(mixed $pks = null, integer $state = 1, integer $userId) : boolean
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
mixed
An optional array of primary key values to update. If not set the instance property value is used.- $state
integer
The publishing state. eg. [0 = unpublished, 1 = published]- $userId
integer
The user ID of the user performing the operation.
Response
boolean
True on success; false if $pks is empty.
reorder
Method to compact the ordering values of rows in a group of rows defined by an SQL WHERE clause.
reorder(string $where = '') : mixed
since |
1.7.0 |
---|---|
throws |
|
Arguments
- $where
string
WHERE clause to use for limiting the selection of rows to compact the ordering values.
Response
mixed
Boolean 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
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 = '') : boolean
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|object
An associative array or object to bind to the Table instance.- $orderingFilter
string
Filter for the order updating- $ignore
array|string
An optional array or space separated list of properties to ignore while binding.
Response
boolean
True on success.
setColumnAlias
Method to register a column alias for a "special" column.
setColumnAlias(string $column, string $columnAlias) : void
since |
3.4 |
---|
Arguments
- $column
string
The "special" column (ie ordering)- $columnAlias
string
The real column name (ie foo_ordering)
setDbo
Method to set the \JDatabaseDriver object.
setDbo(\JDatabaseDriver $db) : boolean
since |
1.7.0 |
---|
Arguments
- $db
\JDatabaseDriver
A \JDatabaseDriver object to be used by the table object.
Response
boolean
True on success.
setRules
Method to set rules for the record.
setRules(mixed $input) : void
since |
1.7.0 |
---|
Arguments
- $input
mixed
A \JAccessRules object, JSON string, or array.
store
Method to store a row in the database from the Table instance properties.
store(boolean $updateNulls = false) : boolean
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
boolean
True to update fields even if they are null.
Response
boolean
True on success.
Properties
_includePaths
Include paths for searching for Table classes.
since |
3.0.0 |
---|
Type(s)
array
tableFields
Table fields cache
since |
3.10.4 |
---|
Type(s)
array
_tbl
Name of the database table to model.
since |
1.7.0 |
---|
Type(s)
string
_tbl_key
Name of the primary key field in the table.
since |
1.7.0 |
---|
Type(s)
string
_tbl_keys
Name of the primary key fields in the table.
since |
3.0.1 |
---|
Type(s)
array
_trackAssets
Should rows be tracked as ACL assets?
since |
1.7.0 |
---|
Type(s)
boolean
_rules
The rules associated with this record.
since |
1.7.0 |
---|
Type(s)
\JAccessRules
_locked
Indicator that the tables have been locked.
since |
1.7.0 |
---|
Type(s)
boolean
_autoincrement
Indicates that the primary keys autoincrement.
since |
3.1.4 |
---|
Type(s)
boolean
_observers
Generic observers for this Table (Used e.g. for tags Processing)
_columnAlias
Array with alias for "special" columns such as ordering, hits etc etc
since |
3.4.0 |
---|
Type(s)
array
_jsonEncode
An array of key names to be json encoded in the bind function
since |
3.3 |
---|
Type(s)
array
_supportNullValue
Indicates that columns fully support the NULL value in the database
since |
3.10.0 |
---|
Type(s)
boolean