JTableContent
Extends \JTableContent table
Parent class to all tables.
package |
Joomla.Platform |
---|---|
subpackage |
Table |
since |
11.1 |
Methods
__construct
Class constructor, overridden in descendant classes.
__construct(mixed $properties = null)
since |
11.1 |
---|
Arguments
- $properties
mixed
Either and associative array or another object to set the initial properties of the object.
__toString
Magic method to convert the object to a string gracefully.
__toString() : string
since |
11.1 |
---|---|
deprecated |
12.3 Classes should provide their own __toString() implementation. |
Response
string
The classname.
_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 |
11.1 |
---|
Response
string
_getAssetParentId
Method to get the parent asset under which to register this one.
_getAssetParentId(\JTable $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. The extended class can define a table and id to lookup. If the asset does not exist it will be created.
since |
11.1 |
---|
Arguments
- $table
\JTable
A JTable 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. 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.
_getAssetTitle() : string
link | |
---|---|
since |
11.1 |
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 |
11.1 |
---|---|
throws |
|
Response
boolean
True on success.
_unlock
Method to unlock the database table for writing.
_unlock() : boolean
since |
11.1 |
---|
Response
boolean
True on success.
addIncludePath
Add a filesystem path where JTable should search for table class files.
addIncludePath(mixed $path = null) : array
You may either pass a string or an array of paths.
link | |
---|---|
since |
11.1 |
Arguments
- $path
mixed
A filesystem path or array of filesystem paths to add.
Response
array
An array of filesystem paths to find JTable classes in.
bind
Method to bind an associative array or object to the JTable instance.This method only binds properties that are publicly accessible and optionally takes an array of properties to ignore when binding.
bind(mixed $src, mixed $ignore = array()) : boolean
link | |
---|---|
since |
11.1 |
Arguments
- $src
mixed
An associative array or object to bind to the JTable instance.- $ignore
mixed
An optional array or space separated list of properties to ignore while binding.
Response
boolean
True on success.
canDelete
Generic check for whether dependencies exist for this object in the database schema
canDelete(mixed $pk = null, array $joins = null) : boolean
Can be overloaded/supplemented by the child class
deprecated |
12.1 |
---|---|
link | |
since |
11.1 |
Arguments
- $pk
mixed
An optional primary key value check the row for. If not set the instance property value is used.- $joins
array
An optional array to compiles standard joins formatted like: [label => 'Label', name => 'table name' , idfield => 'field', joinfield => 'field']
Response
boolean
True on success.
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.
check() : boolean
link | |
---|---|
since |
11.1 |
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. Checking a row in will allow other users the ability to edit the row.
checkIn(mixed $pk = null) : boolean
link | |
---|---|
since |
11.1 |
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. 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.
checkOut(integer $userId, mixed $pk = null) : boolean
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.
link | |
---|---|
since |
11.1 |
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.
def
Sets a default value if not alreay assigned
def(string $property, mixed $default = null) : mixed
since |
11.1 |
---|
Arguments
- $property
string
The name of the property.- $default
mixed
The default value.
Response
mixed
delete
Method to delete a row from the database table by primary key value.
delete(mixed $pk = null) : boolean
link | |
---|---|
since |
11.1 |
Arguments
- $pk
mixed
An optional primary key value to delete. If not set the instance property value is used.
Response
boolean
True 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
since |
11.1 |
---|---|
see | \JObject::getProperties() |
Arguments
- $property
string
The name of the property.- $default
mixed
The default value.
Response
mixed
The value of the property.
getDbo
Method to get the JDatabase connector object.
getDbo() : \JDatabase
getError
Get the most recent error message.
getError(integer $i = null, boolean $toString = true) : string
since |
11.1 |
---|---|
see | \JError |
deprecated |
12.3 JError has been deprecated |
Arguments
- $i
integer
Option error index.- $toString
boolean
Indicates if JError objects should return their error message.
Response
string
Error message
getErrors
Return all errors, if any.
getErrors() : array
since |
11.1 |
---|---|
see | \JError |
deprecated |
12.3 JError has been deprecated |
Response
array
Array of error messages or JErrors.
getFields
Get the columns from database table.
getFields() : mixed
since |
11.1 |
---|
Response
mixed
An array of the field names, or false if an error occurs.
getInstance
Static method to get an instance of a JTable class if it can be found in the table include paths. To add include paths for searching for JTable classes @see JTable::addIncludePath().
getInstance(string $type, string $prefix = 'JTable', array $config = array()) : mixed
link | |
---|---|
since |
11.1 |
Arguments
- $type
string
The type (name) of the JTable 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 JTable object.
Response
mixed
A JTable object if found or boolean false if one could not be found.
getKeyName
Method to get the primary key field name for the table.
getKeyName() : string
link | |
---|---|
since |
11.1 |
Response
string
The name of the primary key for the table.
getNextOrder
Method to get the next ordering value for a group of rows defined by an SQL WHERE clause.
getNextOrder(string $where = '') : mixed
This is useful for placing a new item last in a group of items in the table.
link | |
---|---|
since |
11.1 |
Arguments
- $where
string
WHERE clause to use for selecting the MAX(ordering) for the table.
Response
mixed
Boolean false an failure or the next ordering value as an integer.
getProperties
Returns an associative array of object properties.
getProperties(boolean $public = true) : array
since |
11.1 |
---|---|
see | \JObject::get() |
Arguments
- $public
boolean
If true, returns only the public properties.
Response
array
getRules
Method to get the rules for the record.
getRules() : \JAccessRules
getTableName
Method to get the database table name for the class.
getTableName() : string
since |
11.1 |
---|---|
link |
Response
string
The name of the database table being modeled.
hit
Method to increment the hits for a row if the necessary property/field exists.
hit(mixed $pk = null) : boolean
link | |
---|---|
since |
11.1 |
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. If the row is checked out by the same user, then it is considered not checked out -- as the user can still edit it.
isCheckedOut(integer $with, integer $against = null) : boolean
link | |
---|---|
since |
11.1 |
todo |
This either needs to be static or not. |
Arguments
- $with
integer
The userid to preform the match with, if an item is checked out by this user the function will return false.- $against
integer
The userid 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 JTable instance properties.
load(mixed $keys = null, boolean $reset = true) : boolean
link | |
---|---|
since |
11.1 |
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 or on error (internal error state set in that case).
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 = '') : mixed
Negative numbers move the row up in the sequence and positive numbers move it down.
link | |
---|---|
since |
11.1 |
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
mixed
Boolean true on success.
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.
publish(mixed $pks = null, integer $state = 1, integer $userId) : boolean
link | |
---|---|
since |
11.1 |
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.
reorder
Method to compact the ordering values of rows in a group of rows defined by an SQL WHERE clause.
reorder(string $where = '') : mixed
link | |
---|---|
since |
11.1 |
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.
reset() : void
link | |
---|---|
since |
11.1 |
save
Method to provide a shortcut to binding, checking and storing a JTable 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 JTable instance for the property specified.
save(mixed $src, string $orderingFilter = '', mixed $ignore = '') : boolean
link | |
---|---|
since |
11.1 |
Arguments
- $src
mixed
An associative array or object to bind to the JTable instance.- $orderingFilter
string
Filter for the order updating- $ignore
mixed
An optional array or space separated list of properties to ignore while binding.
Response
boolean
True on success.
set
Modifies a property of the object, creating it if it does not already exist.
set(string $property, mixed $value = null) : mixed
since |
11.1 |
---|
Arguments
- $property
string
The name of the property.- $value
mixed
The value of the property to set.
Response
mixed
Previous value of the property.
setDBO
Method to set the JDatabase connector object.
setDBO( &$db) : boolean
setError
Add an error message.
setError(string $error) : void
since |
11.1 |
---|---|
see | \JError |
deprecated |
12.3 JError has been deprecated |
Arguments
- $error
string
Error message.
setProperties
Set the object properties based on a named array/hash.
setProperties(mixed $properties) : boolean
since |
11.1 |
---|---|
see | \JObject::set() |
Arguments
- $properties
mixed
Either an associative array or another object.
Response
boolean
setRules
Method to set rules for the record.
setRules(mixed $input) : void
since |
11.1 |
---|
Arguments
- $input
mixed
A JAccessRules object, JSON string, or array.
store
Method to store a row in the database from the JTable 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 JTable instance.
link | |
---|---|
since |
11.1 |
Arguments
- $updateNulls
boolean
True to update fields even if they are null.
Response
boolean
True on success.
toString
Converts the object to a string (the class name).
toString() : string
toXML
Method to export the JTable instance properties to an XML string.
toXML(boolean $mapKeysToText = false) : string
deprecated |
12.1 |
---|---|
link | |
since |
11.1 |
Arguments
- $mapKeysToText
boolean
True to map foreign keys to text values.
Response
string
XML string representation of the instance.
Properties
_tbl
Name of the database table to model.
since |
11.1 |
---|
Type(s)
string
_tbl_key
Name of the primary key field in the table.
since |
11.1 |
---|
Type(s)
string
_trackAssets
Should rows be tracked as ACL assets?
since |
11.1 |
---|
Type(s)
boolean
_locked
Indicator that the tables have been locked.
since |
11.1 |
---|
Type(s)
boolean
_errors
An array of error messages or Exception objects.