API16

JModel/ construct: Difference between revisions

From Joomla! Documentation

Doxiki (talk | contribs)
New page: ===Description=== Constructor <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>Edit Descripton<nowiki>]</nowiki> </span> {{De...
 
m preparing for archive only
 
(One intermediate revision by the same user not shown)
Line 2: Line 2:
Constructor
Constructor


<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JModel/__construct|Edit Descripton]]<nowiki>]</nowiki>
</span>


{{Description:JModel/__construct}}
 
 


===Syntax===
===Syntax===
Line 69: Line 67:
</source>
</source>


<span class="editsection" style="font-size:76%;">
 
<nowiki>[</nowiki>[[SeeAlso:JModel/__construct|Edit See Also]]<nowiki>]</nowiki>
 
</span>
{{SeeAlso:JModel/__construct}}


===Examples===
===Examples===
<CodeExamplesForm />
=== Code Examples ===
<dpl>
<dpl>
  noresultsheader=\n
  noresultsheader=\n
  category=__construct
  category=__construct
  category=JModel
  category=JModel
  category=CodeExample
  namespace=CodeExample
  category=MethodExample
  category=MethodExample
  include=*
  include=*
  format= ,,,
  format= ,,,
</dpl>
</dpl>

Latest revision as of 01:54, 25 March 2017

Description

Constructor



Syntax

__construct($config=array())
Parameter Name Default Value Description
$config array()

Defined in

libraries/joomla/application/component/model.php

Importing

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

Source Body

function __construct($config = array())
{
        //set the view name
        if (empty($this->_name))
        {
                if (array_key_exists('name', $config))  {
                        $this->_name = $config['name'];
                } else {
                        $this->_name = $this->getName();
                }
        }

        //set the model state
        if (array_key_exists('state', $config))  {
                $this->_state = $config['state'];
        } else {
                $this->_state = new JObject();
        }

        //set the model dbo
        if (array_key_exists('dbo', $config))  {
                $this->_db = $config['dbo'];
        } else {
                $this->_db = &JFactory::getDbo();
        }

        // set the default view search path
        if (array_key_exists('table_path', $config)) {
                $this->addTablePath($config['table_path']);
        } else if (defined('JPATH_COMPONENT_ADMINISTRATOR')){
                $this->addTablePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables');
        }

        // set the internal state marker - used to ignore setting state from the request
        if (!empty($config['ignore_request'])) {
                $this->__state_set = true;
        }
}



Examples

Code Examples