Документация по Joomla 1.7

Joomla.Platform\JTable
libraries/joomla/database/table.php at line 23

Class JTable

JObject
└─JTable
All Known Subclasses:
Joomla.Administrator\BannersTableBanner Joomla.Administrator\BannersTableClient Joomla.Administrator\ContactTableContact Joomla.Administrator\ContentTableFeatured JTableContent JTableExtension JTableLanguage JTableMenuType JTableModule JTableNested JTableSession JTableUpdate JTableUser JTableUsergroup JTableViewlevel Joomla.Administrator\MessagesTableMessage Joomla.Administrator\NewsfeedsTableNewsfeed Joomla.Administrator\RedirectTableLink Joomla.Administrator\TemplatesTableStyle Joomla.Administrator\WeblinksTableWeblink

public abstract class JTable
extends JObject

Abstract Table class

Parent class to all tables.

Subpackage:
Table
Since:
11.1
Tutorial:
Joomla.Platform/jtable.cls
See Also:
http://docs.joomla.org/JTable

Field Summary
protected object

$_db

JDatabase connector object.

protected boolean

$_locked

Indicator that the tables have been locked.

protected JRules A JRules object.

$_rules

The rules associated with this record.

protected string

$_tbl

Name of the database table to model.

protected string

$_tbl_key

Name of the primary key field in the table.

protected boolean

$_trackAssets

Should rows be tracked as ACL assets?

Fields inherited from Joomla.Platform\JObject
_errors
Constructor Summary
JObject

__construct(mixed table, mixed key, mixed db, string Name, object JDatabase, mixed properties)

Object constructor to set table and key fields.

Method Summary
mixed

getFields()

Get the columns from database table.

static mixed

getInstance(string The, array An, mixed type, str prefix, mixed config)

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

static array

addIncludePath(mixed A, mixed path)

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

protected static string

_getAssetName()

Method to compute the default name of the asset.

protected string

_getAssetTitle()

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

protected integer

_getAssetParentId(JTable table, integer id)

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

string

getTableName()

Method to get the database table name for the class.

string

getKeyName()

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

object

getDbo()

Method to get the JDatabase connector object.

boolean

setDBO(object &$db, mixed db)

Method to set the JDatabase connector object.

void

setRules(mixed input)

Method to set rules for the record.

JRules

getRules()

Method to get the rules for the record.

void

reset()

Method to reset class properties to the defaults set in the class definition.

boolean

bind(mixed src, mixed ignore)

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.

boolean

load(mixed keys, boolean reset)

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

boolean

check()

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

boolean

store(boolean updateNulls)

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

boolean

save(mixed src, string orderingFilter, mixed ignore)

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

boolean

delete(mixed pk)

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

boolean

checkOut(integer userId, mixed pk)

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

boolean

checkIn(mixed pk)

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

boolean

hit(mixed pk)

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

boolean

isCheckedOut(integer with, integer against)

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

mixed

getNextOrder(string where)

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

mixed

reorder(string where)

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

mixed

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.

boolean

publish(mixed pk, integer state, integer userId, mixed pks)

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

boolean

canDelete(mixed pk, array joins)

Generic check for whether dependancies exist for this object in the database schemaCan be overloaded/supplemented by the child class

string

toXML(boolean mapKeysToText)

Method to export the JTable instance properties to an XML string.

protected boolean

_lock()

Method to lock the database table for writing.

protected boolean

_unlock()

Method to unlock the database table for writing.

Methods inherited from Joomla.Platform\JObject
__construct, __toString, def, get, getError, getErrors, getProperties, set, setError, setProperties, toString

Field Detail

libraries/joomla/database/table.php at line 47

_db

protected object $_db

JDatabase connector object.

Since:
11.1

libraries/joomla/database/table.php at line 70

_locked

protected boolean $_locked = false

Indicator that the tables have been locked.

Since:
11.1

libraries/joomla/database/table.php at line 62

_rules

protected JRules A JRules object. $_rules

The rules associated with this record.


libraries/joomla/database/table.php at line 31

_tbl

protected string $_tbl = ''

Name of the database table to model.

Since:
11.1

libraries/joomla/database/table.php at line 39

_tbl_key

protected string $_tbl_key = ''

Name of the primary key field in the table.

Since:
11.1

libraries/joomla/database/table.php at line 55

_trackAssets

protected boolean $_trackAssets = false

Should rows be tracked as ACL assets?

Since:
11.1

Constructor Detail

libraries/joomla/database/table.php at line 83

__construct

public JObject __construct(mixed table, mixed key, mixed db, string Name, object JDatabase, mixed properties)

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:
Name - of the table to model.
Name - of the primary key field in the table.
JDatabase - connector object.
Since:
11.1

Method Detail

libraries/joomla/database/table.php at line 118

getFields

public mixed getFields()

Get the columns from database table.

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

libraries/joomla/database/table.php at line 150

getInstance

public static mixed getInstance(string The, array An, mixed type, str prefix, mixed config)

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

Parameters:
The - type (name) of the JTable class to get an instance of.
An - optional prefix for the table class name.
An - optional array of configuration values for the JTable object.
Returns:
A JTable object if found or boolean false if one could not be found.
Since:
11.1
See Also:
http://docs.joomla.org/JTable/getInstance

libraries/joomla/database/table.php at line 196

addIncludePath

public static array addIncludePath(mixed A, mixed path)

Add a filesystem path where JTable should search for table class files. You may either pass a string or an array of paths.

Parameters:
A - filesystem path or array of filesystem paths to add.
Returns:
An array of filesystem paths to find JTable classes in.
See Also:
http://docs.joomla.org/JTable/addIncludePath
Since:
11.1

libraries/joomla/database/table.php at line 234

_getAssetName

protected static string _getAssetName()

Method to compute the default name of the asset. 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

libraries/joomla/database/table.php at line 252

_getAssetTitle

protected string _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 woud just return $this->title or $this->name or whatever is being used for the primary name of the row. If this method is not overriden, the asset name is used.

Returns:
The string to use as the title in the asset table.
See Also:
http://docs.joomla.org/JTable/getAssetTitle
Since:
11.1

libraries/joomla/database/table.php at line 270

_getAssetParentId

protected integer _getAssetParentId(JTable table, integer id)

Method to get the parent asset under which to register this one. By default, all assets are registered to the ROOT node with ID 1. The extended class can define a table and id to lookup. If the asset does not exist it will be created.

Parameters:
table - A JTable object for the asset parent.
id - Id to look up
Since:
11.1

libraries/joomla/database/table.php at line 289

getTableName

public string getTableName()

Method to get the database table name for the class.

Returns:
The name of the database table being modeled.
Since:
11.1
See Also:
http://docs.joomla.org/JTable/getTableName

libraries/joomla/database/table.php at line 302

getKeyName

public string getKeyName()

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

Returns:
The name of the primary key for the table.
See Also:
http://docs.joomla.org/JTable/getKeyName
Since:
11.1

libraries/joomla/database/table.php at line 315

getDbo

public object getDbo()

Method to get the JDatabase connector object.

Returns:
The internal database connector object.
See Also:
http://docs.joomla.org/JTable/getDBO
Since:
11.1

libraries/joomla/database/table.php at line 330

setDBO

public boolean setDBO(object &$db, mixed db)

Method to set the JDatabase connector object.

Parameters:
&$db - A JDatabase connector object to be used by the table object.
Returns:
True on success.
See Also:
http://docs.joomla.org/JTable/setDBO
Since:
11.1

libraries/joomla/database/table.php at line 349

setRules

public void setRules(mixed input)

Method to set rules for the record.

Parameters:
input - A JRules object, JSON string, or array.
Since:
11.1

libraries/joomla/database/table.php at line 366

getRules

public JRules getRules()

Method to get the rules for the record.

Returns:
object
Since:
11.1

libraries/joomla/database/table.php at line 381

reset

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

See Also:
http://docs.joomla.org/JTable/reset
Since:
11.1

libraries/joomla/database/table.php at line 407

bind

public boolean bind(mixed src, mixed ignore)

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.

Parameters:
src - An associative array or object to bind to the JTable instance.
ignore - An optional array or space separated list of properties to ignore while binding.
Returns:
True on success.
See Also:
http://docs.joomla.org/JTable/bind
Since:
11.1

libraries/joomla/database/table.php at line 453

load

public boolean load(mixed keys, boolean reset)

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

Parameters:
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.
reset - True to reset the default values before loading the new row.
Returns:
True if successful. False if row not found or on error (internal error state set in that case).
See Also:
http://docs.joomla.org/JTable/load
Since:
11.1

libraries/joomla/database/table.php at line 526

check

public boolean 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.

Returns:
True if the instance is sane and able to be stored in the database.
See Also:
http://docs.joomla.org/JTable/check
Since:
11.1

libraries/joomla/database/table.php at line 545

store

public boolean store(boolean updateNulls)

Method to store a row in the database from the JTable instance properties. 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.

Parameters:
updateNulls - True to update fields even if they are null.
Returns:
True on success.
See Also:
http://docs.joomla.org/JTable/store
Since:
11.1

libraries/joomla/database/table.php at line 656

save

public boolean save(mixed src, string orderingFilter, mixed ignore)

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.

Parameters:
src - An associative array or object to bind to the JTable instance.
orderingFilter - Filter for the order updating
ignore - An optional array or space separated list of properties to ignore while binding.
Returns:
True on success.
See Also:
http://docs.joomla.org/JTable/save
Since:
11.1

libraries/joomla/database/table.php at line 701

delete

public boolean delete(mixed pk)

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

Parameters:
pk - An optional primary key value to delete. If not set the instance property value is used.
Returns:
True on success.
See Also:
http://docs.joomla.org/JTable/delete
Since:
11.1

libraries/joomla/database/table.php at line 767

checkOut

public boolean checkOut(integer userId, mixed pk)

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. 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:
userId - The Id of the user checking out the row.
pk - An optional primary key value to check out. If not set the instance property value is used.
Returns:
True on success.
See Also:
http://docs.joomla.org/JTable/checkOut
Since:
11.1

libraries/joomla/database/table.php at line 821

checkIn

public boolean checkIn(mixed pk)

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:
pk - An optional primary key value to check out. If not set the instance property value is used.
Returns:
True on success.
See Also:
http://docs.joomla.org/JTable/checkIn
Since:
11.1

libraries/joomla/database/table.php at line 872

hit

public boolean hit(mixed pk)

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

Parameters:
pk - An optional primary key value to increment. If not set the instance property value is used.
Returns:
True on success.
See Also:
http://docs.joomla.org/JTable/hit
Since:
11.1

libraries/joomla/database/table.php at line 924

isCheckedOut

public boolean isCheckedOut(integer with, integer against)

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:
with - The userid to preform the match with, if an item is checked out by this user the function will return false.
against - The userid to perform the match against when the function is used as a static function.
Returns:
True if checked out.
See Also:
http://docs.joomla.org/JTable/isCheckedOut
Since:
11.1
Todo:
This either needs to be static or not.

libraries/joomla/database/table.php at line 959

getNextOrder

public mixed 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:
where - WHERE clause to use for selecting the MAX(ordering) for the table.
Returns:
Boolean false an failure or the next ordering value as an integer.
See Also:
http://docs.joomla.org/JTable/getNextOrder
Since:
11.1

libraries/joomla/database/table.php at line 1006

reorder

public mixed reorder(string where)

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

Parameters:
where - WHERE clause to use for limiting the selection of rows to compact the ordering values.
Returns:
Boolean true on success.
See Also:
http://docs.joomla.org/JTable/reorder
Since:
11.1

libraries/joomla/database/table.php at line 1086

move

public mixed 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:
delta - The direction and magnitude to move the row in the ordering sequence.
where - WHERE clause to use for limiting the selection of rows to compact the ordering values.
Returns:
Boolean true on success.
See Also:
http://docs.joomla.org/JTable/move
Since:
11.1

libraries/joomla/database/table.php at line 1199

publish

public boolean publish(mixed pk, integer state, integer userId, mixed pks)

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.

Parameters:
pk - An optional array of primary key values to update. If not set the instance property value is used.
state - The publishing state. eg. [0 = unpublished, 1 = published]
userId - The user id of the user performing the operation.
Returns:
True on success.
See Also:
http://docs.joomla.org/JTable/publish
Since:
11.1

libraries/joomla/database/table.php at line 1284

canDelete

public boolean canDelete(mixed pk, array joins)

Generic check for whether dependancies exist for this object in the database schema

Can be overloaded/supplemented by the child class

Parameters:
pk - An optional primary key value check the row for. If not set the instance property value is used.
joins - An optional array to compiles standard joins formatted like: [label => 'Label', name => 'table name' , idfield => 'field', joinfield => 'field']
Returns:
True on success.
Deprecated:
12.1
See Also:
http://docs.joomla.org/JTable/canDelete
Since:
11.1

libraries/joomla/database/table.php at line 1360

toXML

public string toXML(boolean mapKeysToText)

Method to export the JTable instance properties to an XML string.

Parameters:
mapKeysToText - True to map foreign keys to text values.
Returns:
XML string representation of the instance.
Deprecated:
12.1
See Also:
http://docs.joomla.org/JTable/toXML
Since:
11.1

libraries/joomla/database/table.php at line 1394

_lock

protected boolean _lock()

Method to lock the database table for writing.

Returns:
True on success.
Since:
11.1

libraries/joomla/database/table.php at line 1419

_unlock

protected boolean _unlock()

Method to unlock the database table for writing.

Returns:
True on success.
Since:
11.1

Документация по Joomla 1.7