API17

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__
<span class="editsection" style="font-size:76%;">
+
=={{JVer|11.1}} JModel==
<nowiki>[</nowiki>[[Description:JModel|Edit Descripton]]<nowiki>]</nowiki>
+
===Description===
</span>
+
[[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]]
{{Description:JModel}}
+
 
===Defined in===
+
===The Joomla MVC Design Pattern===
libraries/joomla/application/component/model.php
+
Model-View-Controller (MVC) is a set of design patterns, that are used to separate the different layers of your application.
===Subpackage===
+
 
[[Subpackage Application/11.1|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.
===Extends===
+
* The '''Model''' stores the data of the application, and contains the business logic. Joomla implements the basic functionality in the abstract JModel class.  
[[JObject/11.1|JObject]]
+
* 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.
===Extended by===
+
 
* [[JModelForm/11.1|JModelForm]]
 
* [[JModelItem/11.1|JModelItem]]
 
* [[JModelList/11.1|JModelList]]
 
 
===Methods===
 
===Methods===
 
{| class="wikitable sortable"
 
{| class="wikitable sortable"
 
|-
 
|-
 +
!Visibility
 
!Method name
 
!Method name
 
!Description
 
!Description
 
|-
 
|-
|[[JModel::__construct/11.1|__construct]]
+
|public
 +
|[[API17:JModel::__construct|__construct]]
 
|Constructor.  
 
|Constructor.  
 
|-
 
|-
|[[JModel::getDbo/11.1|getDbo]]
+
|public
 +
|[[API17:JModel::getDbo|getDbo]]
 
|Method to get the database connector object.  
 
|Method to get the database connector object.  
 
|-
 
|-
|[[JModel::getName/11.1|getName]]
+
|public
 +
|[[API17:JModel::getName|getName]]
 
|Method to get the model name.  
 
|Method to get the model name.  
 
|-
 
|-
|[[JModel::getState/11.1|getState]]
+
|public
 +
|[[API17:JModel::getState|getState]]
 
|Method to get model state variables.  
 
|Method to get model state variables.  
 
|-
 
|-
|[[JModel::getTable/11.1|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/11.1|setDbo]]
+
|public
 +
|[[API17:JModel::setDbo|setDbo]]
 
|Method to set the database connector object.  
 
|Method to set the database connector object.  
 
|-
 
|-
|[[JModel::setState/11.1|setState]]
+
|public
 +
|[[API17:JModel::setState|setState]]
 
|Method to set model state variables.  
 
|Method to set model state variables.  
 
|-
 
|-
|[[JModel::addIncludePath/11.1|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/11.1|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/11.1|getInstance]]
+
|public static
 +
|[[API17:JModel::getInstance|getInstance]]
 
|Returns a Model object, always creating it.  
 
|Returns a Model object, always creating it.  
 
|-
 
|-
|[[JModel::_getList/11.1|_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/11.1|_getListCount]]
+
|protected
 +
|[[API17:JModel::_getListCount|_getListCount]]
 
|Returns a record count for the query.  
 
|Returns a record count for the query.  
 
|-
 
|-
|[[JModel::populateState/11.1|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===
* [[JModel|Other versions of this class]]
+
* {{JVer|11.1}} '''JModel source code''' on [[jplatform:application/component/model.php|BitBucket]]
{{SeeAlso:JModel}}
+
* {{JVer|11.1}} Subpackage [[API17:Subpackage Application|Application]]
<span class="editsection" style="font-size:76%;">
+
* [[API17:JModel|Other versions of JModel]]
<nowiki>[</nowiki>[[SeeAlso:JModel|Edit See Also]]<nowiki>]</nowiki>
+
 
</span>
+
 
===Examples===
+
===User contributed notes===
<CodeExamplesForm />
+
=== Code Examples ===
 
<dpl>
 
<dpl>
 
noresultsheader=\n
 
noresultsheader=\n
 
category=JModel
 
category=JModel
category=CodeExample
+
namespace=CodeExample
 
category=ClassExample
 
category=ClassExample
 
include=*
 
include=*
 +
namespace=CodeExample
 
format= ,,,
 
format= ,,,
 
</dpl>
 
</dpl>
<noinclude>[[Category:Platform]][[Category:Platform 11.1]][[Category:JModel]]</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.

Joomla 11.1 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.

Importing[edit]

jimport( 'joomla.application.component.model' );

See also[edit]


User contributed notes[edit]

Code Examples[edit]