Difference between revisions of "JModel"
From Joomla! Documentation
(Bulk upload by Doxiki2) |
m (preparing for archive only) |
||
(7 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
− | + | =={{JVer|11.1}} JModel== | |
− | + | ===Description=== | |
− | + | [[JModel]] is an abstract class which provides the basic functionality for concrete model objects in conjunction with Joomla's MVC pattern. Models that extend the JModel class are often defined in Joomla components and define the business logic of the specific component. See [[Developing_a_Model-View-Controller_Component_-_Part_1 | MVC Development in Joomla]] | |
− | {{ | + | |
− | + | ===The Joomla MVC Design Pattern=== | |
− | + | Model-View-Controller (MVC) is a set of design patterns, that are used to separate the different layers of your application. | |
− | === | + | |
− | [[ | + | * The '''View''' displays the data of the model by passing it to a template. The view object can therefore access the data of the model. Joomla implements the basic functionality in the abstract JView class. |
− | === | + | * The '''Model''' stores the data of the application, and contains the business logic. Joomla implements the basic functionality in the abstract JModel class. |
− | + | * The '''Controller''' handles the user requests and evokes the model and the views to change it's state. Joomla implements the basic functionality in the JController class. | |
− | + | ||
− | * | ||
− | * | ||
− | * | ||
===Methods=== | ===Methods=== | ||
{| class="wikitable sortable" | {| class="wikitable sortable" | ||
|- | |- | ||
+ | !Visibility | ||
!Method name | !Method name | ||
!Description | !Description | ||
|- | |- | ||
− | |[[JModel::__construct | + | |public |
+ | |[[API17:JModel::__construct|__construct]] | ||
|Constructor. | |Constructor. | ||
|- | |- | ||
− | |[[JModel::getDbo | + | |public |
+ | |[[API17:JModel::getDbo|getDbo]] | ||
|Method to get the database connector object. | |Method to get the database connector object. | ||
|- | |- | ||
− | |[[JModel::getName | + | |public |
+ | |[[API17:JModel::getName|getName]] | ||
|Method to get the model name. | |Method to get the model name. | ||
|- | |- | ||
− | |[[JModel::getState | + | |public |
+ | |[[API17:JModel::getState|getState]] | ||
|Method to get model state variables. | |Method to get model state variables. | ||
|- | |- | ||
− | |[[JModel::getTable | + | |public |
+ | |[[API17:JModel::getTable|getTable]] | ||
|Method to get a table object, load it if necessary. | |Method to get a table object, load it if necessary. | ||
|- | |- | ||
− | |[[JModel::setDbo | + | |public |
+ | |[[API17:JModel::setDbo|setDbo]] | ||
|Method to set the database connector object. | |Method to set the database connector object. | ||
|- | |- | ||
− | |[[JModel::setState | + | |public |
+ | |[[API17:JModel::setState|setState]] | ||
|Method to set model state variables. | |Method to set model state variables. | ||
|- | |- | ||
− | |[[JModel::addIncludePath | + | |public static |
+ | |[[API17:JModel::addIncludePath|addIncludePath]] | ||
|Add a directory where should search for models. | |Add a directory where should search for models. | ||
|- | |- | ||
− | |[[JModel::addTablePath | + | |public static |
+ | |[[API17:JModel::addTablePath|addTablePath]] | ||
|Adds to the stack of model table paths in LIFO order. | |Adds to the stack of model table paths in LIFO order. | ||
|- | |- | ||
− | |[[JModel::getInstance | + | |public static |
+ | |[[API17:JModel::getInstance|getInstance]] | ||
|Returns a Model object, always creating it. | |Returns a Model object, always creating it. | ||
|- | |- | ||
− | |[[JModel::_getList | + | |protected |
+ | |[[API17:JModel::_getList|_getList]] | ||
|Gets an array of objects from the results of database query. | |Gets an array of objects from the results of database query. | ||
|- | |- | ||
− | |[[JModel::_getListCount | + | |protected |
+ | |[[API17:JModel::_getListCount|_getListCount]] | ||
|Returns a record count for the query. | |Returns a record count for the query. | ||
|- | |- | ||
− | |[[JModel::populateState | + | |protected |
+ | |[[API17:JModel::populateState|populateState]] | ||
|Method to auto-populate the model state. | |Method to auto-populate the model state. | ||
|- | |- | ||
|} | |} | ||
+ | * '''Defined in''' libraries/joomla/application/component/model.php | ||
+ | * '''Extends''' [[API17:JObject|JObject]] | ||
+ | * '''Extended by''' | ||
+ | ** [[API17:JModelForm|JModelForm]] | ||
+ | ** [[API17:JModelItem|JModelItem]] | ||
+ | ** [[API17:JModelList|JModelList]] | ||
===Importing=== | ===Importing=== | ||
<source lang="php">jimport( 'joomla.application.component.model' );</source> | <source lang="php">jimport( 'joomla.application.component.model' );</source> | ||
===See also=== | ===See also=== | ||
− | * [[ | + | * {{JVer|11.1}} '''JModel source code''' on [[jplatform:application/component/model.php|BitBucket]] |
− | {{ | + | * {{JVer|11.1}} Subpackage [[API17:Subpackage Application|Application]] |
− | + | * [[API17:JModel|Other versions of JModel]] | |
− | + | ||
− | + | ||
− | ===Examples=== | + | ===User contributed notes=== |
− | + | === Code Examples === | |
<dpl> | <dpl> | ||
noresultsheader=\n | noresultsheader=\n | ||
category=JModel | category=JModel | ||
− | + | namespace=CodeExample | |
category=ClassExample | category=ClassExample | ||
include=* | include=* | ||
+ | namespace=CodeExample | ||
format= ,,, | format= ,,, | ||
</dpl> | </dpl> | ||
− | <noinclude> | + | <noinclude>[[Category:Platform 11.1]][[Category:Archived pages API17]]</noinclude> |
Latest revision as of 22:26, 24 March 2017
The "API17" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.
JModel[edit]
Description[edit]
JModel is an abstract class which provides the basic functionality for concrete model objects in conjunction with Joomla's MVC pattern. Models that extend the JModel class are often defined in Joomla components and define the business logic of the specific component. See MVC Development in Joomla
The Joomla MVC Design Pattern[edit]
Model-View-Controller (MVC) is a set of design patterns, that are used to separate the different layers of your application.
- The View displays the data of the model by passing it to a template. The view object can therefore access the data of the model. Joomla implements the basic functionality in the abstract JView class.
- The Model stores the data of the application, and contains the business logic. Joomla implements the basic functionality in the abstract JModel class.
- The Controller handles the user requests and evokes the model and the views to change it's state. Joomla implements the basic functionality in the JController class.
Methods[edit]
Visibility | Method name | Description |
---|---|---|
public | __construct | Constructor. |
public | getDbo | Method to get the database connector object. |
public | getName | Method to get the model name. |
public | getState | Method to get model state variables. |
public | getTable | Method to get a table object, load it if necessary. |
public | setDbo | Method to set the database connector object. |
public | setState | Method to set model state variables. |
public static | addIncludePath | Add a directory where should search for models. |
public static | addTablePath | Adds to the stack of model table paths in LIFO order. |
public static | getInstance | Returns a Model object, always creating it. |
protected | _getList | Gets an array of objects from the results of database query. |
protected | _getListCount | Returns a record count for the query. |
protected | populateState | Method to auto-populate the model state. |
- Defined in libraries/joomla/application/component/model.php
- Extends JObject
- Extended by
Importing[edit]
jimport( 'joomla.application.component.model' );
See also[edit]
- JModel source code on BitBucket
- Subpackage Application
- Other versions of JModel
User contributed notes[edit]
Code Examples[edit]