Joomla! Platform 12.1

Abstract Class JModel

Description

Base class for a Joomla Model

Acts as a Factory class for application specific objects and provides many supporting API functions.

  • abstract:
  • since: 11.1

Located in /libraries/joomla/application/component/model.php (line 22)

Class JObject   (Subpackage Base)

Abstract class JModel   (Subpackage Application)
Direct descendents
Class Description
Abstract classJModelItem Prototype item model.
ClassJModelList Model class for handling lists of items.
Abstract classJModelForm Prototype form model.
Variable Summary
Variable object $db
Variable string $name
Variable string $option
Variable string $state
Variable boolean $stateSet
Variable object $_db
Variable boolean $__state_set
Method Summary
Static method static array addIncludePath ([mixed $path = ''], [string $prefix = ''])
Static method static void addTablePath (mixed $path)
Static method static mixed getInstance (string $type, [string $prefix = ''], [array $config = array()])
Static method static string _createFileName (string $type, [array $parts = array()])
Constructor JModel __construct ([array $config = array()])
Method void cleanCache ([string $group = null], [integer $client_id = 0])
Method string getName ()
Method object The getState ([string $property = null], [mixed $default = null])
Method JTable getTable ([string $name = ''], [string $prefix = 'Table'], [array $options = array()])
Method void populateState ()
Method void setDbo (object &$db)
Method mixed setState (string $property, [mixed $value = null])
Method mixed _createTable (string $name, [string $prefix = 'Table'], [array $config = array()])
Method array _getList (string $query, [integer $limitstart = 0], [integer $limit = 0])
Method integer _getListCount (string $query)
Variables
object $db (line 47)

Database Connector

  • since: 11.1
  • access: protected
string $event_clean_cache = null (line 90)

The event to trigger when cleaning cache.

  • since: 11.1
  • access: protected
string $name (line 65)

The model (base) name

  • since: 11.1
  • access: protected
string $option = null (line 73)

The URL option for the component.

  • since: 11.1
  • access: protected
string $state (line 82)

A state object

  • since: 11.1
  • access: protected
boolean $stateSet = null (line 30)

Indicates if the internal state has been set

  • since: 11.1
  • access: protected
object $_db (line 56)

Database Connector

  • deprecated: use $db declare as private
  • since: 11.1
  • access: protected
boolean $__state_set = null (line 39)

Indicates if the internal state has been set

  • deprecated: use $stateSet declare as private
  • since: 11.1
  • access: protected

Inherited Variables

Inherited from JObject

Variable JObject::$_errors
Methods
Constructor __construct (line 229)

Constructor

  • since: 11.1
  • access: public
JModel __construct ([array $config = array()])
  • array $config: An array of configuration options (name, state, dbo, table_path, ignore_request).

Redefinition of:
JObject::__construct()
Class constructor, overridden in descendant classes.

Redefined in descendants as:
addIncludePath (line 103)

Add a directory where JModel should search for models. You may either pass a string or an array of directories.

  • return: An array with directory elements. If prefix is equal to '', all directories are returned.
  • since: 11.1
  • access: public
array addIncludePath ([mixed $path = ''], [string $prefix = ''])
  • mixed $path: A path or array[sting] of paths to search.
  • string $prefix: A prefix for models.
addTablePath (line 149)

Adds to the stack of model table paths in LIFO order.

  • since: 11.1
  • access: public
void addTablePath (mixed $path)
  • mixed $path: The directory as a string or directories as an array to add.
cleanCache (line 510)

Clean the cache

  • since: 11.1
  • access: protected
void cleanCache ([string $group = null], integer $client_id)
  • string $group: The cache group
  • integer $client_id: The ID of the client
getDbo (line 373)

Method to get the database connector object

  • return: JDatabase connector object
  • access: public
JDatabase getDbo ()
getInstance (line 190)

Returns a Model object, always creating it

  • return: A model object or false on failure
  • since: 11.1
  • access: public
mixed getInstance (string $type, [string $prefix = ''], [array $config = array()])
  • string $type: The model type to instantiate
  • string $prefix: Prefix for the model class name. Optional.
  • array $config: Configuration array for model. Optional.
getName (line 388)

Method to get the model name

The model name. By default parsed using the classname or it can be set by passing a $config['name'] in the class constructor

  • return: The name of the model
  • since: 11.1
  • access: public
string getName ()
getState (line 413)

Method to get model state variables

  • return: property where specified, the state object where omitted
  • since: 11.1
  • access: public
object The getState ([string $property = null], [mixed $default = null])
  • string $property: Optional parameter name
  • mixed $default: Optional default value
getTable (line 438)

Method to get a table object, load it if necessary.

  • return: A JTable object
  • since: 11.1
  • access: public
JTable getTable ([string $name = ''], [string $prefix = 'Table'], [array $options = array()])
  • string $name: The table name. Optional.
  • string $prefix: The class prefix. Optional.
  • array $options: Configuration array for model. Optional.
populateState (line 467)

Method to auto-populate the model state.

This method should only be called once per instantiation and is designed to be called on the first call to the getState() method unless the model configuration flag to ignore the request is set.

  • since: 11.1
  • access: protected
void populateState ()

Redefined in descendants as:
setDbo (line 480)

Method to set the database connector object

  • since: 11.1
  • access: public
void setDbo (object &$db)
  • object &$db: A JDatabase based object
setState (line 495)

Method to set model state variables

  • return: The previous value of the property or null if not set.
  • since: 11.1
  • access: public
mixed setState (string $property, [mixed $value = null])
  • string $property: The name of the property.
  • mixed $value: The value of the property to set or null.
_createFileName (line 165)

Create the filename for a resource

  • return: The filename
  • since: 11.1
  • access: protected
string _createFileName (string $type, [array $parts = array()])
  • string $type: The resource type to create the filename for.
  • array $parts: An associative array of filename information.
_createTable (line 353)

Method to load and return a model object.

  • return: Model object or boolean false if failed
  • see: JTable::getInstance
  • since: 11.1
  • access: protected
mixed _createTable (string $name, [string $prefix = 'Table'], [array $config = array()])
  • string $name: The name of the view
  • string $prefix: The class prefix. Optional.
  • array $config: Configuration settings to pass to JTable::getInstance
_getList (line 316)

Gets an array of objects from the results of database query.

  • return: An array of results.
  • since: 11.1
  • access: protected
array _getList (string $query, integer $limitstart, integer $limit)
  • string $query: The query.
  • integer $limitstart: Offset.
  • integer $limit: The number of records.
_getListCount (line 333)

Returns a record count for the query

  • return: Number of rows for query
  • since: 11.1
  • access: protected
integer _getListCount (string $query)
  • string $query: The query.

Inherited Methods

Inherited From JObject

 JObject::__construct()
 JObject::def()
 JObject::get()
 JObject::getError()
 JObject::getErrors()
 JObject::getProperties()
 JObject::set()
 JObject::setError()
 JObject::setProperties()
 JObject::toString()
 JObject::__toString()
/html>