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

Joomla.Platform\JModel
libraries/joomla/application/component/model.php at line 22

Class JModel

JObject
└─JModel
All Known Subclasses:
Joomla.Administrator\AdminModelHelp Joomla.Administrator\AdminModelSysInfo Joomla.Site\BannersModelBanner Joomla.Site\ContactModelCategories Joomla.Site\ContentModelCategories Joomla.Administrator\InstallerModelInstall Joomla.Installation\JInstallationModelConfiguration Joomla.Installation\JInstallationModelDatabase Joomla.Installation\JInstallationModelFilesystem Joomla.Installation\JInstallationModelMigration Joomla.Installation\JInstallationModelSetup JModelForm JModelItem JModelList Joomla.Administrator\LoginModelLogin Joomla.Administrator\MediaModelList Joomla.Administrator\MediaModelManager Joomla.Site\NewsfeedsModelCategories Joomla.Site\SearchModelSearch Joomla.Administrator\TemplatesModelTemplate Joomla.Site\WeblinksModelCategories

public abstract class JModel
extends JObject

Base class for a Joomla Model

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

Subpackage:
Application
Since:
11.1

Field Summary
protected boolean

$__state_set

Indicates if the internal state has been set

protected object

$_db

Database Connector

protected string

$event_clean_cache

The event to trigger when cleaning cache.

protected string

$name

The model (base) name

protected string

$option

The URL option for the component.

protected string

$state

A state object

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

__construct(array config, mixed properties)

Constructor

Method Summary
static array

addIncludePath(mixed path, string prefix)

Add a directory where JModel should search for models.

static void

addTablePath(mixed path)

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

protected static string

_createFileName(string type, array parts)

Create the filename for a resource

static mixed

getInstance(string type, string prefix, array config)

Returns a Model object, always creating it

protected array

_getList(string query, integer limitstart, integer limit)

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

protected integer

_getListCount(string query)

Returns a record count for the query

protected mixed

_createTable(string name, string prefix, array config)

Method to load and return a model object.

JDatabase

getDbo()

Method to get the database connector object

string

getName()

Method to get the model nameThe model name.

object

getState(string property, mixed default)

Method to get model state variables

JTable

getTable(string name, string prefix, array options)

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

protected void

populateState()

Method to auto-populate the model state.

void

setDbo(object &$db, mixed db)

Method to set the database connector object

mixed

setState(string property, mixed value)

Method to set model state variables

protected void

cleanCache(string group, string client_id)

Clean the cache

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

Field Detail

libraries/joomla/application/component/model.php at line 30

__state_set

protected boolean $__state_set = null

Indicates if the internal state has been set

Since:
11.1

libraries/joomla/application/component/model.php at line 38

_db

protected object $_db

Database Connector

Since:
11.1

libraries/joomla/application/component/model.php at line 72

event_clean_cache

protected string $event_clean_cache = null

The event to trigger when cleaning cache.

Since:
11.1

libraries/joomla/application/component/model.php at line 47

name

protected string $name

The model (base) name

Note:
Replaces _name variable in 11.1
Since:
11.1

libraries/joomla/application/component/model.php at line 55

option

protected string $option = null

The URL option for the component.

Since:
11.1

libraries/joomla/application/component/model.php at line 64

state

protected string $state

A state object

Note:
Replaces _state variable in 11.1
Since:
11.1

Constructor Detail

libraries/joomla/application/component/model.php at line 202

__construct

public JModel __construct(array config, mixed properties)

Constructor

Parameters:
config - An array of configuration options (name, state, dbo, table_path, ignore_request).
Returns:
A JModel object
Since:
11.1

Method Detail

libraries/joomla/application/component/model.php at line 84

addIncludePath

public static array addIncludePath(mixed path, string prefix)

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

Parameters:
path - A path or array[sting] of paths to search.
prefix - A prefix for models.
Returns:
An array with directory elements. If prefix is equal to '', all directories are returned.
Since:
11.1

libraries/joomla/application/component/model.php at line 123

addTablePath

public static void addTablePath(mixed path)

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

Parameters:
path - The directory as a string or directories as an array to add.
Since:
11.1

libraries/joomla/application/component/model.php at line 138

_createFileName

protected static string _createFileName(string type, array parts)

Create the filename for a resource

Parameters:
type - The resource type to create the filename for.
parts - An associative array of filename information.
Returns:
The filename
Since:
11.1

libraries/joomla/application/component/model.php at line 161

getInstance

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

Returns a Model object, always creating it

Parameters:
type - The model type to instantiate
prefix - Prefix for the model class name. Optional.
config - Configuration array for model. Optional.
Returns:
A model object or false on failure
Since:
11.1

libraries/joomla/application/component/model.php at line 273

_getList

protected array _getList(string query, integer limitstart, integer limit)

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

Parameters:
query - The query.
limitstart - Offset.
limit - The number of records.
Returns:
An array of results.
Since:
11.1

libraries/joomla/application/component/model.php at line 289

_getListCount

protected integer _getListCount(string query)

Returns a record count for the query

Parameters:
query - The query.
Returns:
Number of rows for query
Since:
11.1

libraries/joomla/application/component/model.php at line 308

_createTable

protected mixed _createTable(string name, string prefix, array config)

Method to load and return a model object.

Parameters:
name - The name of the view
prefix - The class prefix. Optional.
config - Configuration settings to pass to JTable::getInsance
Returns:
Model object or boolean false if failed
Since:
11.1
See Also:
JTable::getInstance

libraries/joomla/application/component/model.php at line 327

getDbo

public JDatabase getDbo()

Method to get the database connector object

Returns:
JDatabase connector object

libraries/joomla/application/component/model.php at line 341

getName

public string getName()

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

Returns:
The name of the model
Since:
11.1

libraries/joomla/application/component/model.php at line 365

getState

public object getState(string property, mixed default)

Method to get model state variables

Parameters:
property - Optional parameter name
default - Optional default value
Returns:
The property where specified, the state object where omitted
Since:
11.1

libraries/joomla/application/component/model.php at line 388

getTable

public JTable getTable(string name, string prefix, array options)

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

Parameters:
name - The table name. Optional.
prefix - The class prefix. Optional.
options - Configuration array for model. Optional.
Returns:
A JTable object
Since:
11.1

libraries/joomla/application/component/model.php at line 415

populateState

protected void populateState()

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.

Note:
Calling getState in this method will result in recursion.
Since:
11.1

libraries/joomla/application/component/model.php at line 427

setDbo

public void setDbo(object &$db, mixed db)

Method to set the database connector object

Parameters:
&$db - A JDatabase based object
Since:
11.1

libraries/joomla/application/component/model.php at line 441

setState

public mixed setState(string property, mixed value)

Method to set model state variables

Parameters:
property - The name of the property.
value - The value of the property to set or null.
Returns:
The previous value of the property or null if not set.
Since:
11.1

libraries/joomla/application/component/model.php at line 456

cleanCache

protected void cleanCache(string group, string client_id)

Clean the cache

Parameters:
group - The cache group
client_id - The ID of the client
Since:
11.1

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