Joomla Platform  13.1
Documentation des API du framework Joomla Platform
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Pages
Référence de la classe JTable
+ Graphe d'héritage de JTable:
+ Graphe de collaboration de JTable:

Liste de tous les membres

Fonctions membres publiques

 __construct ($table, $key, JDatabaseDriver $db)
 attachObserver (JObserverInterface $observer)
 getObserverOfClass ($observerClass)
 getFields ()
 appendPrimaryKeys ($query, $pk=null)
 getTableName ()
 getKeyName ($multiple=false)
 getDbo ()
 setDBO (JDatabaseDriver $db)
 setRules ($input)
 getRules ()
 reset ()
 bind ($src, $ignore=array())
 load ($keys=null, $reset=true)
 check ()
 store ($updateNulls=false)
 save ($src, $orderingFilter= '', $ignore= '')
 delete ($pk=null)
 checkOut ($userId, $pk=null)
 checkIn ($pk=null)
 hasPrimaryKey ()
 hit ($pk=null)
 isCheckedOut ($with=0, $against=null)
 getNextOrder ($where= '')
 getPrimaryKey (array $keys=array())
 reorder ($where= '')
 move ($delta, $where= '')
 publish ($pks=null, $state=1, $userId=0)
- Fonctions membres publiques inherited from JObject
 __construct ($properties=null)
 __toString ()
 def ($property, $default=null)
 get ($property, $default=null)
 getProperties ($public=true)
 getError ($i=null, $toString=true)
 getErrors ()
 set ($property, $value=null)
 setProperties ($properties)
 setError ($error)

Fonctions membres publiques statiques

static getInstance ($type, $prefix= 'JTable', $config=array())
static addIncludePath ($path=null)

Fonctions membres protégées

 _getAssetName ()
 _getAssetTitle ()
 _getAssetParentId (JTable $table=null, $id=null)
 _lock ()
 _unlock ()

Attributs protégés

 $_tbl = ''
 $_tbl_key = ''
 $_tbl_keys = array()
 $_db
 $_trackAssets = false
 $_rules
 $_locked = false
 $_autoincrement = true
 $_observers
- Attributs protégés inherited from JObject
 $_errors = array()

Attributs privés statiques

static $_includePaths = array()

Description détaillée

Définition à la ligne 25 du fichier table.php.


Documentation des constructeurs et destructeur

JTable::__construct (   $table,
  $key,
JDatabaseDriver  $db 
)

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.

Paramètres:
string$tableName of the table to model.
mixed$keyName of the primary key field in the table or array of field names that compose the primary key.
JDatabaseDriver$dbJDatabaseDriver object.
Depuis:
11.1

Définition à la ligne 118 du fichier table.php.

Références JFactory\getConfig().

{
// Set internal variables.
$this->_tbl = $table;
// Set the key to be an array.
if (is_string($key))
{
$key = array($key);
}
elseif (is_object($key))
{
$key = (array) $key;
}
$this->_tbl_keys = $key;
if (count($key) == 1)
{
$this->_autoincrement = true;
}
else
{
$this->_autoincrement = false;
}
// Set the singular table key for backwards compatibility.
$this->_tbl_key = $this->getKeyName();
$this->_db = $db;
// Initialise the table properties.
$fields = $this->getFields();
if ($fields)
{
foreach ($fields as $name => $v)
{
// Add the field if it is not already present.
if (!property_exists($this, $name))
{
$this->$name = null;
}
}
}
// If we are tracking assets, make sure an access field exists and initially set the default.
if (property_exists($this, 'asset_id'))
{
$this->_trackAssets = true;
}
// If the access property exists, set the default.
if (property_exists($this, 'access'))
{
$this->access = (int) JFactory::getConfig()->get('access');
}
// Implement JObservableInterface:
// Create observer updater and attaches all observers interested by $this class:
$this->_observers = new JObserverUpdater($this);
JObserverMapper::attachAllObservers($this);
}

+ Voici le graphe d'appel pour cette fonction :


Documentation des fonctions membres

JTable::_getAssetName ( )
protected

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.

Renvoie:
string
Depuis:
11.1

Réimplémentée dans JTableContent, JTableCategory, et JTableModule.

Définition à la ligne 348 du fichier table.php.

{
$keys = array();
foreach ($this->_tbl_keys as $k)
{
$keys[] = (int) $this->$k;
}
return $this->_tbl . '.' . implode('.', $keys);
}
JTable::_getAssetParentId ( JTable  $table = null,
  $id = null 
)
protected

Method to get the parent asset under which to register this one. 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.

Paramètres:
JTable$tableA JTable object for the asset parent.
integer$idId to look up
Renvoie:
integer
Depuis:
11.1

Réimplémentée dans JTableContent, JTableCategory, et JTableModule.

Définition à la ligne 391 du fichier table.php.

{
// For simple cases, parent to the asset root.
$assets = self::getInstance('Asset', 'JTable', array('dbo' => $this->getDbo()));
$rootId = $assets->getRootId();
if (!empty($rootId))
{
return $rootId;
}
return 1;
}
JTable::_getAssetTitle ( )
protected

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.

Renvoie:
string The string to use as the title in the asset table.

11.1

Réimplémentée dans JTableContent, JTableCategory, et JTableModule.

Définition à la ligne 372 du fichier table.php.

{
return $this->_getAssetName();
}
JTable::_lock ( )
protected

Method to lock the database table for writing.

Renvoie:
boolean True on success.
Depuis:
11.1
Exceptions:
RuntimeException

Définition à la ligne 1597 du fichier table.php.

{
$this->_db->lockTable($this->_tbl);
$this->_locked = true;
return true;
}
JTable::_unlock ( )
protected

Method to unlock the database table for writing.

Renvoie:
boolean True on success.
Depuis:
11.1

Définition à la ligne 1612 du fichier table.php.

{
$this->_db->unlockTables();
$this->_locked = false;
return true;
}
static JTable::addIncludePath (   $path = null)
static

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

Paramètres:
mixed$pathA filesystem path or array of filesystem paths to add.
Renvoie:
array An array of filesystem paths to find JTable classes in.

11.1

Définition à la ligne 308 du fichier table.php.

Référencé par JModelLegacy\addTablePath().

{
// If the internal paths have not been initialised, do so with the base table path.
if (empty(self::$_includePaths))
{
self::$_includePaths = array(__DIR__);
}
// Convert the passed path(s) to add to an array.
settype($path, 'array');
// If we have new paths to add, do so.
if (!empty($path))
{
// Check and add each individual new path.
foreach ($path as $dir)
{
// Sanitize path.
$dir = trim($dir);
// Add to the front of the list so that custom paths are searched first.
if (!in_array($dir, self::$_includePaths))
{
array_unshift(self::$_includePaths, $dir);
}
}
}
}

+ Voici le graphe des appelants de cette fonction :

JTable::appendPrimaryKeys (   $query,
  $pk = null 
)

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

Paramètres:
JDatabaseQuery$queryA query object to append.
mixed$pkOptional primary key parameter.
Renvoie:
void
Depuis:
12.3

Définition à la ligne 415 du fichier table.php.

{
if (is_null($pk))
{
foreach ($this->_tbl_keys as $k)
{
$query->where($this->_db->quoteName($k) . ' = ' . $this->_db->quote($this->$k));
}
}
else
{
if (is_string($pk))
{
$pk = array($this->_tbl_key => $pk);
}
$pk = (object) $pk;
foreach ($this->_tbl_keys AS $k)
{
$query->where($this->_db->quoteName($k) . ' = ' . $this->_db->quote($pk->$k));
}
}
}
JTable::attachObserver ( JObserverInterface  $observer)

Implement JObservableInterface: Adds an observer to this instance. This method will be called fron the constructor of classes implementing JObserverInterface which is instanciated by the constructor of $this with JObserverMapper::attachAllObservers($this)

Paramètres:
JObserverInterface | JTableObserver$observerThe observer object
Renvoie:
void
Depuis:
3.1.2

Implémente JObservableInterface.

Définition à la ligne 194 du fichier table.php.

Référencé par JTableObserver\__construct().

{
$this->_observers->attachObserver($observer);
}

+ Voici le graphe des appelants de cette fonction :

JTable::bind (   $src,
  $ignore = array() 
)

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.

Paramètres:
mixed$srcAn associative array or object to bind to the JTable instance.
mixed$ignoreAn optional array or space separated list of properties to ignore while binding.
Renvoie:
boolean True on success.

11.1 InvalidArgumentException

Réimplémentée dans JTableCategory, JTableModule, JTableContent, JTableUser, JTableExtension, JTableUpdate, JTableMenu, et JTableViewlevel.

Définition à la ligne 587 du fichier table.php.

Référencé par JModelLegacy\loadHistory().

{
// If the source value is not an array or object return false.
if (!is_object($src) && !is_array($src))
{
throw new InvalidArgumentException(sprintf('%s::bind(*%s*)', get_class($this), gettype($src)));
}
// If the source value is an object, get its accessible properties.
if (is_object($src))
{
$src = get_object_vars($src);
}
// If the ignore value is a string, explode it over spaces.
if (!is_array($ignore))
{
$ignore = explode(' ', $ignore);
}
// Bind the source value, excluding the ignored fields.
foreach ($this->getProperties() as $k => $v)
{
// Only process fields not in the ignore array.
if (!in_array($k, $ignore))
{
if (isset($src[$k]))
{
$this->$k = $src[$k];
}
}
}
return true;
}

+ Voici le graphe des appelants de cette fonction :

JTable::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.

Renvoie:
boolean True if the instance is sane and able to be stored in the database.

11.1

Réimplémentée dans JTableNested, JTableContent, JTableUser, JTableCategory, JTableModule, JTableAsset, JTableMenu, JTableViewlevel, JTableExtension, JTableUpdate, JTableMenuType, JTableLanguage, et JTableUsergroup.

Définition à la ligne 735 du fichier table.php.

{
return true;
}
JTable::checkIn (   $pk = null)

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.

Paramètres:
mixed$pkAn optional primary key value to check out. If not set the instance property value is used.
Renvoie:
boolean True on success.

11.1 UnexpectedValueException

Définition à la ligne 1081 du fichier table.php.

Référencé par JModelLegacy\loadHistory().

{
// If there is no checked_out or checked_out_time field, just return true.
if (!property_exists($this, 'checked_out') || !property_exists($this, 'checked_out_time'))
{
return true;
}
if (is_null($pk))
{
$pk = array();
foreach ($this->_tbl_keys AS $key)
{
$pk[$this->$key] = $this->$key;
}
}
elseif (!is_array($pk))
{
$pk = array($this->_tbl_key => $pk);
}
foreach ($this->_tbl_keys AS $key)
{
$pk[$key] = empty($pk[$key]) ? $this->$key : $pk[$key];
if ($pk[$key] === null)
{
throw new UnexpectedValueException('Null primary key not allowed.');
}
}
// Check the row in by primary key.
$query = $this->_db->getQuery(true)
->update($this->_tbl)
->set($this->_db->quoteName('checked_out') . ' = 0')
->set($this->_db->quoteName('checked_out_time') . ' = ' . $this->_db->quote($this->_db->getNullDate()));
$this->appendPrimaryKeys($query, $pk);
$this->_db->setQuery($query);
// Check for a database error.
$this->_db->execute();
// Set table values in the object.
$this->checked_out = 0;
$this->checked_out_time = '';
return true;
}

+ Voici le graphe des appelants de cette fonction :

JTable::checkOut (   $userId,
  $pk = null 
)

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.

Paramètres:
integer$userIdThe Id of the user checking out the row.
mixed$pkAn optional primary key value to check out. If not set the instance property value is used.
Renvoie:
boolean True on success.

11.1 UnexpectedValueException

Définition à la ligne 1018 du fichier table.php.

Références JFactory\getDate().

{
// If there is no checked_out or checked_out_time field, just return true.
if (!property_exists($this, 'checked_out') || !property_exists($this, 'checked_out_time'))
{
return true;
}
if (is_null($pk))
{
$pk = array();
foreach ($this->_tbl_keys AS $key)
{
$pk[$key] = $this->$key;
}
}
elseif (!is_array($pk))
{
$pk = array($this->_tbl_key => $pk);
}
foreach ($this->_tbl_keys AS $key)
{
$pk[$key] = is_null($pk[$key]) ? $this->$key : $pk[$key];
if ($pk[$key] === null)
{
throw new UnexpectedValueException('Null primary key not allowed.');
}
}
// Get the current time in the database format.
$time = JFactory::getDate()->toSql();
// Check the row out by primary key.
$query = $this->_db->getQuery(true)
->update($this->_tbl)
->set($this->_db->quoteName('checked_out') . ' = ' . (int) $userId)
->set($this->_db->quoteName('checked_out_time') . ' = ' . $this->_db->quote($time));
$this->appendPrimaryKeys($query, $pk);
$this->_db->setQuery($query);
$this->_db->execute();
// Set table values in the object.
$this->checked_out = (int) $userId;
$this->checked_out_time = $time;
return true;
}

+ Voici le graphe d'appel pour cette fonction :

JTable::delete (   $pk = null)

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

Paramètres:
mixed$pkAn optional primary key value to delete. If not set the instance property value is used.
Renvoie:
boolean True on success.

11.1 UnexpectedValueException

Réimplémentée dans JTableUser, JTableSession, JTableMenuType, et JTableUsergroup.

Définition à la ligne 930 du fichier table.php.

{
if (is_null($pk))
{
$pk = array();
foreach ($this->_tbl_keys AS $key)
{
$pk[$key] = $this->$key;
}
}
elseif (!is_array($pk))
{
$pk = array($this->_tbl_key => $pk);
}
foreach ($this->_tbl_keys AS $key)
{
$pk[$key] = is_null($pk[$key]) ? $this->$key : $pk[$key];
if ($pk[$key] === null)
{
throw new UnexpectedValueException('Null primary key not allowed.');
}
$this->$key = $pk[$key];
}
// Implement JObservableInterface: Pre-processing by observers
$this->_observers->update('onBeforeDelete', array($pk));
// If tracking assets, remove the asset first.
if ($this->_trackAssets)
{
// Get the asset name
$name = $this->_getAssetName();
$asset = self::getInstance('Asset');
if ($asset->loadByName($name))
{
if (!$asset->delete())
{
$this->setError($asset->getError());
return false;
}
}
else
{
$this->setError($asset->getError());
return false;
}
}
// Delete the row by primary key.
$query = $this->_db->getQuery(true)
->delete($this->_tbl);
$this->appendPrimaryKeys($query, $pk);
$this->_db->setQuery($query);
// Check for a database error.
$this->_db->execute();
// Implement JObservableInterface: Post-processing by observers
$this->_observers->update('onAfterDelete', array($pk));
return true;
}
JTable::getDbo ( )

Method to get the JDatabaseDriver object.

Renvoie:
JDatabaseDriver The internal database driver object.

11.1

Définition à la ligne 492 du fichier table.php.

{
return $this->_db;
}
JTable::getFields ( )

Get the columns from database table.

Renvoie:
mixed An array of the field names, or false if an error occurs.
Depuis:
11.1
Exceptions:
UnexpectedValueException

Définition à la ligne 221 du fichier table.php.

{
static $cache = null;
if ($cache === null)
{
// Lookup the fields for this table only once.
$name = $this->_tbl;
$fields = $this->_db->getTableColumns($name, false);
if (empty($fields))
{
throw new UnexpectedValueException(sprintf('No columns found for %s table', $name));
}
$cache = $fields;
}
return $cache;
}
static JTable::getInstance (   $type,
  $prefix = 'JTable',
  $config = array() 
)
static

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

Paramètres:
string$typeThe type (name) of the JTable class to get an instance of.
string$prefixAn optional prefix for the table class name.
array$configAn optional array of configuration values for the JTable object.
Renvoie:
mixed A JTable object if found or boolean false if one could not be found.

11.1

Définition à la ligne 256 du fichier table.php.

Références JLog\add(), JPath\find(), JFactory\getDbo(), JText\sprintf(), et JLog\WARNING.

Référencé par JModelLegacy\_createTable(), JUpdaterExtension\_startElement(), JUpdaterCollection\_startElement(), JAccess\check(), JModelAdmin\checkCategoryId(), JAccess\checkGroup(), JTableMenuType\delete(), JTableNested\delete(), JUpdater\findUpdates(), JAccess\getAssetRules(), JUser\getTable(), JModelLegacy\loadHistory(), JTableLanguage\store(), JTableMenuType\store(), JTableMenu\store(), JTableCategory\store(), JTableContent\store(), et JUpdater\update().

{
// Sanitize and prepare the table class name.
$type = preg_replace('/[^A-Z0-9_\.-]/i', '', $type);
$tableClass = $prefix . ucfirst($type);
// Only try to load the class if it doesn't already exist.
if (!class_exists($tableClass))
{
// Search for the class file in the JTable include paths.
$path = JPath::find(self::addIncludePath(), strtolower($type) . '.php');
if ($path)
{
// Import the class file.
include_once $path;
// If we were unable to load the proper class, raise a warning and return false.
if (!class_exists($tableClass))
{
JLog::add(JText::sprintf('JLIB_DATABASE_ERROR_CLASS_NOT_FOUND_IN_FILE', $tableClass), JLog::WARNING, 'jerror');
return false;
}
}
else
{
// If we were unable to find the class file in the JTable include paths, raise a warning and return false.
JLog::add(JText::sprintf('JLIB_DATABASE_ERROR_NOT_SUPPORTED_FILE_NOT_FOUND', $type), JLog::WARNING, 'jerror');
return false;
}
}
// If a database object was passed in the configuration array use it, otherwise get the global one from JFactory.
$db = isset($config['dbo']) ? $config['dbo'] : JFactory::getDbo();
// Instantiate a new table class and return it.
return new $tableClass($db);
}

+ Voici le graphe d'appel pour cette fonction :

+ Voici le graphe des appelants de cette fonction :

JTable::getKeyName (   $multiple = false)

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

Paramètres:
boolean$multipleTrue to return all primary keys (as an array) or false to return just the first one (as a string).
Renvoie:
mixed Array of primary key field names or string containing the first primary key field.

11.1

Définition à la ligne 464 du fichier table.php.

Référencé par JModelLegacy\loadHistory().

{
// Count the number of keys
if (count($this->_tbl_keys))
{
if ($multiple)
{
// If we want multiple keys, return the raw array.
}
else
{
// If we want the standard method, just return the first key.
return $this->_tbl_keys[0];
}
}
return '';
}

+ Voici le graphe des appelants de cette fonction :

JTable::getNextOrder (   $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.

Paramètres:
string$whereWHERE clause to use for selecting the MAX(ordering) for the table.
Renvoie:
mixed Boolean false an failure or the next ordering value as an integer.

11.1 UnexpectedValueException

Définition à la ligne 1278 du fichier table.php.

{
// If there is no ordering field set an error and return false.
if (!property_exists($this, 'ordering'))
{
throw new UnexpectedValueException(sprintf('%s does not support ordering.', get_class($this)));
}
// Get the largest ordering value for a given where clause.
$query = $this->_db->getQuery(true)
->select('MAX(ordering)')
->from($this->_tbl);
if ($where)
{
$query->where($where);
}
$this->_db->setQuery($query);
$max = (int) $this->_db->loadResult();
// Return the largest ordering value + 1.
return ($max + 1);
}
JTable::getObserverOfClass (   $observerClass)

Gets the instance of the observer of class $observerClass

Paramètres:
string$observerClassThe observer class-name to return the object of
Renvoie:
JTableObserver|null
Depuis:
3.1.2

Définition à la ligne 208 du fichier table.php.

{
return $this->_observers->getObserverOfClass($observerClass);
}
JTable::getPrimaryKey ( array  $keys = array())

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

Paramètres:
array$keysOptional primary key values to use.
Renvoie:
array An array of primary key names and values.
Depuis:
12.3

Définition à la ligne 1312 du fichier table.php.

{
foreach ($this->_tbl_keys as $key)
{
if (!isset($keys[$key]))
{
if (!empty($this->$key))
{
$keys[$key] = $this->$key;
}
}
}
return $keys;
}
JTable::getRules ( )

Method to get the rules for the record.

Renvoie:
JAccessRules object
Depuis:
11.1

Définition à la ligne 542 du fichier table.php.

{
return $this->_rules;
}
JTable::getTableName ( )

Method to get the database table name for the class.

Renvoie:
string The name of the database table being modeled.
Depuis:
11.1

http://docs.joomla.org/JTable/getTableName

Définition à la ligne 449 du fichier table.php.

{
return $this->_tbl;
}
JTable::hasPrimaryKey ( )

Validate that the primary key has been set.

Renvoie:
boolean True if the primary key(s) have been set.
Depuis:
12.3

Définition à la ligne 1138 du fichier table.php.

{
if ($this->_autoincrement)
{
$empty = true;
foreach ($this->_tbl_keys as $key)
{
$empty = $empty && empty($this->$key);
}
}
else
{
$query = $this->_db->getQuery(true)
->select('COUNT(*)')
->from($this->_tbl);
$this->appendPrimaryKeys($query);
$this->_db->setQuery($query);
$count = $this->_db->loadResult();
if ($count == 1)
{
$empty = false;
}
else
{
$empty = true;
}
}
return !$empty;
}
JTable::hit (   $pk = null)

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

Paramètres:
mixed$pkAn optional primary key value to increment. If not set the instance property value is used.
Renvoie:
boolean True on success.

11.1 UnexpectedValueException

Définition à la ligne 1183 du fichier table.php.

{
// If there is no hits field, just return true.
if (!property_exists($this, 'hits'))
{
return true;
}
if (is_null($pk))
{
$pk = array();
foreach ($this->_tbl_keys AS $key)
{
$pk[$key] = $this->$key;
}
}
elseif (!is_array($pk))
{
$pk = array($this->_tbl_key => $pk);
}
foreach ($this->_tbl_keys AS $key)
{
$pk[$key] = is_null($pk[$key]) ? $this->$key : $pk[$key];
if ($pk[$key] === null)
{
throw new UnexpectedValueException('Null primary key not allowed.');
}
}
// Check the row in by primary key.
$query = $this->_db->getQuery(true)
->update($this->_tbl)
->set($this->_db->quoteName('hits') . ' = (' . $this->_db->quoteName('hits') . ' + 1)');
$this->appendPrimaryKeys($query, $pk);
$this->_db->setQuery($query);
$this->_db->execute();
// Set table values in the object.
$this->hits++;
return true;
}
JTable::isCheckedOut (   $with = 0,
  $against = null 
)

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.

Paramètres:
integer$withThe userid to preform the match with, if an item is checked out by this user the function will return false.
integer$againstThe userid to perform the match against when the function is used as a static function.
Renvoie:
boolean True if checked out.

11.1

Définition à la ligne 1244 du fichier table.php.

Références JFactory\getDbo().

{
// Handle the non-static case.
if (isset($this) && ($this instanceof JTable) && is_null($against))
{
$against = $this->get('checked_out');
}
// The item is not checked out or is checked out by the same user.
if (!$against || ($against == $with))
{
return false;
}
$db->setQuery('SELECT COUNT(userid) FROM ' . $db->quoteName('#__session') . ' WHERE ' . $db->quoteName('userid') . ' = ' . (int) $against);
$checkedOut = (boolean) $db->loadResult();
// If a session exists for the user then it is checked out.
return $checkedOut;
}

+ Voici le graphe d'appel pour cette fonction :

JTable::load (   $keys = null,
  $reset = true 
)

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

Paramètres:
mixed$keysAn 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.
boolean$resetTrue to reset the default values before loading the new row.
Renvoie:
boolean True if successful. False if row not found.

11.1 InvalidArgumentException RuntimeException UnexpectedValueException

Réimplémentée dans JTableUser.

Définition à la ligne 639 du fichier table.php.

{
// Implement JObservableInterface: Pre-processing by observers
$this->_observers->update('onBeforeLoad', array($keys, $reset));
if (empty($keys))
{
$empty = true;
$keys = array();
// If empty, use the value of the current key
foreach ($this->_tbl_keys as $key)
{
$empty = $empty && empty($this->$key);
$keys[$key] = $this->$key;
}
// If empty primary key there's is no need to load anything
if ($empty)
{
return true;
}
}
elseif (!is_array($keys))
{
// Load by primary key.
$keyCount = count($this->_tbl_keys);
if ($keyCount)
{
if ($keyCount > 1)
{
throw new InvalidArgumentException('Table has multiple primary keys specified, only one primary key value provided.');
}
$keys = array($this->getKeyName() => $keys);
}
else
{
throw new RuntimeException('No table keys defined.');
}
}
if ($reset)
{
$this->reset();
}
// Initialise the query.
$query = $this->_db->getQuery(true)
->select('*')
->from($this->_tbl);
$fields = array_keys($this->getProperties());
foreach ($keys as $field => $value)
{
// Check that $field is in the table.
if (!in_array($field, $fields))
{
throw new UnexpectedValueException(sprintf('Missing field in database: %s   %s.', get_class($this), $field));
}
// Add the search tuple to the query.
$query->where($this->_db->quoteName($field) . ' = ' . $this->_db->quote($value));
}
$this->_db->setQuery($query);
$row = $this->_db->loadAssoc();
// Check that we have a result.
if (empty($row))
{
$result = false;
}
else
{
// Bind the object with the row and return.
$result = $this->bind($row);
}
// Implement JObservableInterface: Post-processing by observers
$this->_observers->update('onAfterLoad', array(&$result, $row));
return $result;
}
JTable::move (   $delta,
  $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.

Paramètres:
integer$deltaThe direction and magnitude to move the row in the ordering sequence.
string$whereWHERE clause to use for limiting the selection of rows to compact the ordering values.
Renvoie:
mixed Boolean True on success.

11.1 UnexpectedValueException

Réimplémentée dans JTableNested.

Définition à la ligne 1403 du fichier table.php.

{
// If there is no ordering field set an error and return false.
if (!property_exists($this, 'ordering'))
{
throw new UnexpectedValueException(sprintf('%s does not support ordering.', get_class($this)));
}
// If the change is none, do nothing.
if (empty($delta))
{
return true;
}
$row = null;
$query = $this->_db->getQuery(true);
// Select the primary key and ordering values from the table.
$query->select(implode(',', $this->_tbl_keys) . ', ordering')
->from($this->_tbl);
// If the movement delta is negative move the row up.
if ($delta < 0)
{
$query->where('ordering < ' . (int) $this->ordering)
->order('ordering DESC');
}
// If the movement delta is positive move the row down.
elseif ($delta > 0)
{
$query->where('ordering > ' . (int) $this->ordering)
->order('ordering ASC');
}
// Add the custom WHERE clause if set.
if ($where)
{
$query->where($where);
}
// Select the first row with the criteria.
$this->_db->setQuery($query, 0, 1);
$row = $this->_db->loadObject();
// If a row is found, move the item.
if (!empty($row))
{
// Update the ordering field for this instance to the row's ordering value.
$query->clear()
->update($this->_tbl)
->set('ordering = ' . (int) $row->ordering);
$this->appendPrimaryKeys($query);
$this->_db->setQuery($query);
$this->_db->execute();
// Update the ordering field for the row to this instance's ordering value.
$query->clear()
->update($this->_tbl)
->set('ordering = ' . (int) $this->ordering);
$this->appendPrimaryKeys($query, $row);
$this->_db->setQuery($query);
$this->_db->execute();
// Update the instance value.
$this->ordering = $row->ordering;
}
else
{
// Update the ordering field for this instance.
$query->clear()
->update($this->_tbl)
->set('ordering = ' . (int) $this->ordering);
$this->appendPrimaryKeys($query);
$this->_db->setQuery($query);
$this->_db->execute();
}
return true;
}
JTable::publish (   $pks = null,
  $state = 1,
  $userId = 0 
)

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.

Paramètres:
mixed$pksAn optional array of primary key values to update. If not set the instance property value is used.
integer$stateThe publishing state. eg. [0 = unpublished, 1 = published]
integer$userIdThe user id of the user performing the operation.
Renvoie:
boolean True on success; false if $pks is empty.

11.1

Réimplémentée dans JTableNested, JTableContent, et JTableExtension.

Définition à la ligne 1499 du fichier table.php.

{
if (!is_null($pks))
{
foreach ($pks AS $key => $pk)
{
if (!is_array($pk))
{
$pks[$key] = array($this->_tbl_key => $pk);
}
}
}
$userId = (int) $userId;
$state = (int) $state;
// If there are no primary keys set check to see if the instance key is set.
if (empty($pks))
{
$pk = array();
foreach ($this->_tbl_keys AS $key)
{
if ($this->$key)
{
$pk[$this->$key] = $this->$key;
}
// We don't have a full primary key - return false
else
{
return false;
}
}
$pks = array($pk);
}
foreach ($pks AS $pk)
{
// Update the publishing state for rows with the given primary keys.
$query = $this->_db->getQuery(true)
->update($this->_tbl)
->set('published = ' . (int) $state);
// Determine if there is checkin support for the table.
if (property_exists($this, 'checked_out') || property_exists($this, 'checked_out_time'))
{
$query->where('(checked_out = 0 OR checked_out = ' . (int) $userId . ')');
$checkin = true;
}
else
{
$checkin = false;
}
// Build the WHERE clause for the primary keys.
$this->appendPrimaryKeys($query, $pk);
$this->_db->setQuery($query);
$this->_db->execute();
// If checkin is supported and all rows were adjusted, check them in.
if ($checkin && (count($pks) == $this->_db->getAffectedRows()))
{
$this->checkin($pk);
}
$ours = true;
foreach ($this->_tbl_keys AS $key)
{
if ($this->$key != $pk[$key])
{
$ours = false;
}
}
if ($ours)
{
$this->published = $state;
}
}
$this->setError('');
return true;
}
JTable::reorder (   $where = '')

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

Paramètres:
string$whereWHERE clause to use for limiting the selection of rows to compact the ordering values.
Renvoie:
mixed Boolean True on success.

11.1 UnexpectedValueException

Définition à la ligne 1340 du fichier table.php.

{
// If there is no ordering field set an error and return false.
if (!property_exists($this, 'ordering'))
{
throw new UnexpectedValueException(sprintf('%s does not support ordering.', get_class($this)));
}
// Get the primary keys and ordering values for the selection.
$query = $this->_db->getQuery(true)
->select(implode(',', $this->_tbl_keys) . ', ordering')
->from($this->_tbl)
->where('ordering >= 0')
->order('ordering');
// Setup the extra where and ordering clause data.
if ($where)
{
$query->where($where);
}
$this->_db->setQuery($query);
$rows = $this->_db->loadObjectList();
// Compact the ordering values.
foreach ($rows as $i => $row)
{
// Make sure the ordering is a positive integer.
if ($row->ordering >= 0)
{
// Only update rows that are necessary.
if ($row->ordering != $i + 1)
{
// Update the row ordering field.
$query->clear()
->update($this->_tbl)
->set('ordering = ' . ($i + 1));
$this->appendPrimaryKeys($query, $row);
$this->_db->setQuery($query);
$this->_db->execute();
}
}
}
return true;
}
JTable::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).

Renvoie:
void

11.1

Définition à la ligne 557 du fichier table.php.

{
// Get the default values for the class from the table.
foreach ($this->getFields() as $k => $v)
{
// If the property is not the primary key or private, reset it.
if (!in_array($k, $this->_tbl_keys) && (strpos($k, '_') !== 0))
{
$this->$k = $v->Default;
}
}
// Reset table errors
$this->_errors = array();
}
JTable::save (   $src,
  $orderingFilter = '',
  $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.

Paramètres:
mixed$srcAn associative array or object to bind to the JTable instance.
string$orderingFilterFilter for the order updating
mixed$ignoreAn optional array or space separated list of properties to ignore while binding.
Renvoie:
boolean True on success.

11.1

Définition à la ligne 880 du fichier table.php.

{
// Attempt to bind the source to the instance.
if (!$this->bind($src, $ignore))
{
return false;
}
// Run any sanity checks on the instance and verify that it is ready for storage.
if (!$this->check())
{
return false;
}
// Attempt to store the properties to the database table.
if (!$this->store())
{
return false;
}
// Attempt to check the row in, just in case it was checked out.
if (!$this->checkin())
{
return false;
}
// If an ordering filter is set, attempt reorder the rows in the table based on the filter and value.
if ($orderingFilter)
{
$filterValue = $this->$orderingFilter;
$this->reorder($orderingFilter ? $this->_db->quoteName($orderingFilter) . ' = ' . $this->_db->quote($filterValue) : '');
}
// Set the error to empty and return true.
$this->setError('');
return true;
}
JTable::setDBO ( JDatabaseDriver  $db)

Method to set the JDatabaseDriver object.

Paramètres:
JDatabaseDriver$dbA JDatabaseDriver object to be used by the table object.
Renvoie:
boolean True on success.

11.1

Définition à la ligne 507 du fichier table.php.

{
$this->_db = $db;
return true;
}
JTable::setRules (   $input)

Method to set rules for the record.

Paramètres:
mixed$inputA JAccessRules object, JSON string, or array.
Renvoie:
void
Depuis:
11.1

Définition à la ligne 523 du fichier table.php.

{
if ($input instanceof JAccessRules)
{
$this->_rules = $input;
}
else
{
$this->_rules = new JAccessRules($input);
}
}
JTable::store (   $updateNulls = false)

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.

Paramètres:
boolean$updateNullsTrue to update fields even if they are null.
Renvoie:
boolean True on success.

11.1

Réimplémentée dans JTableNested, JTableUser, JTableContent, JTableCategory, JTableMenu, JTableUsergroup, JTableMenuType, et JTableLanguage.

Définition à la ligne 754 du fichier table.php.

{
// Implement JObservableInterface: Pre-processing by observers
$this->_observers->update('onBeforeStore', array($updateNulls, $k));
$currentAssetId = 0;
if (!empty($this->asset_id))
{
$currentAssetId = $this->asset_id;
}
// The asset id field is managed privately by this class.
if ($this->_trackAssets)
{
unset($this->asset_id);
}
// If a primary key exists update the object, otherwise insert it.
if ($this->hasPrimaryKey())
{
$result = $this->_db->updateObject($this->_tbl, $this, $this->_tbl_keys, $updateNulls);
}
else
{
$result = $this->_db->insertObject($this->_tbl, $this, $this->_tbl_keys[0]);
}
// If the table is not set to track assets return true.
if ($this->_trackAssets)
{
if ($this->_locked)
{
$this->_unlock();
}
/*
* Asset Tracking
*/
$parentId = $this->_getAssetParentId();
$name = $this->_getAssetName();
$title = $this->_getAssetTitle();
$asset = self::getInstance('Asset', 'JTable', array('dbo' => $this->getDbo()));
$asset->loadByName($name);
// Re-inject the asset id.
$this->asset_id = $asset->id;
// Check for an error.
$error = $asset->getError();
if ($error)
{
$this->setError($error);
return false;
}
else
{
// Specify how a new or moved node asset is inserted into the tree.
if (empty($this->asset_id) || $asset->parent_id != $parentId)
{
$asset->setLocation($parentId, 'last-child');
}
// Prepare the asset to be stored.
$asset->parent_id = $parentId;
$asset->name = $name;
$asset->title = $title;
if ($this->_rules instanceof JAccessRules)
{
$asset->rules = (string) $this->_rules;
}
if (!$asset->check() || !$asset->store($updateNulls))
{
$this->setError($asset->getError());
return false;
}
else
{
// Create an asset_id or heal one that is corrupted.
if (empty($this->asset_id) || ($currentAssetId != $this->asset_id && !empty($this->asset_id)))
{
// Update the asset_id field in this table.
$this->asset_id = (int) $asset->id;
$query = $this->_db->getQuery(true)
->update($this->_db->quoteName($this->_tbl))
->set('asset_id = ' . (int) $this->asset_id);
$this->appendPrimaryKeys($query);
$this->_db->setQuery($query)->execute();
}
}
}
}
// Implement JObservableInterface: Post-processing by observers
$this->_observers->update('onAfterStore', array(&$result));
return $result;
}

Documentation des données membres

JTable::$_autoincrement = true
protected

Définition à la ligne 97 du fichier table.php.

JTable::$_db
protected

Définition à la ligne 65 du fichier table.php.

JTable::$_includePaths = array()
staticprivate

Définition à la ligne 33 du fichier table.php.

JTable::$_locked = false
protected

Définition à la ligne 89 du fichier table.php.

JTable::$_observers
protected

Définition à la ligne 105 du fichier table.php.

JTable::$_rules
protected

Définition à la ligne 81 du fichier table.php.

JTable::$_tbl = ''
protected

Définition à la ligne 41 du fichier table.php.

JTable::$_tbl_key = ''
protected

Définition à la ligne 49 du fichier table.php.

JTable::$_tbl_keys = array()
protected

Définition à la ligne 57 du fichier table.php.

JTable::$_trackAssets = false
protected

Définition à la ligne 73 du fichier table.php.


La documentation de cette classe a été générée à partir du fichier suivant :