API15

JModel/ construct

From Joomla! Documentation

< API15:JModel
Revision as of 17:10, 22 March 2010 by Doxiki (talk | contribs)
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

The "API15" 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.

Description[edit]

Constructor

[Edit Descripton]

Template:Description:JModel/ construct

Syntax[edit]

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

Defined in[edit]

libraries/joomla/application/component/model.php

Importing[edit]

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

Source Body[edit]

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');
        }
}

[Edit See Also] Template:SeeAlso:JModel/ construct

Examples[edit]

<CodeExamplesForm />