JModel/getTable: Difference between revisions
From Joomla! Documentation
New page: ===Description===
Method to get a table object, load it if necessary.
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JModel/getTable|Edit Descripton... |
No edit summary |
||
| Line 9: | Line 9: | ||
===Syntax=== | ===Syntax=== | ||
<source lang="php">getTable($name='', $prefix='Table', $options=array())</source> | <source lang="php">& getTable($name='', $prefix='Table', $options=array())</source> | ||
{| class="wikitable" | {| class="wikitable" | ||
| Line 40: | Line 40: | ||
===Source Body=== | ===Source Body=== | ||
<source lang="php"> | <source lang="php"> | ||
function &getTable($name='', $prefix='Table', $options = array()) | |||
{ | { | ||
if (empty($name)) { | if (empty($name)) { | ||
| Line 46: | Line 46: | ||
} | } | ||
if ($table = &$this->_createTable($name, $prefix, $options)) { | if($table = &$this->_createTable( $name, $prefix, $options )) { | ||
return $table; | return $table; | ||
} | } | ||
JError::raiseError(0, 'Table ' . $name . ' not supported. File not found.'); | JError::raiseError( 0, 'Table ' . $name . ' not supported. File not found.' ); | ||
$null = null; | |||
return null; | return $null; | ||
} | } | ||
</source> | </source> | ||
Revision as of 22:10, 22 March 2010
Description
Method to get a table object, load it if necessary.
Template:Description:JModel/getTable
Syntax
& getTable($name='', $prefix='Table', $options=array())
| Parameter Name | Default Value | Description |
|---|---|---|
| $name | The table name. Optional. | |
| $prefix | 'Table' | The class prefix. Optional. |
| $options | array() | Configuration array for model. Optional. |
Returns
object The table
Defined in
libraries/joomla/application/component/model.php
Importing
jimport( 'joomla.application.component.model' );
Source Body
function &getTable($name='', $prefix='Table', $options = array())
{
if (empty($name)) {
$name = $this->getName();
}
if($table = &$this->_createTable( $name, $prefix, $options )) {
return $table;
}
JError::raiseError( 0, 'Table ' . $name . ' not supported. File not found.' );
$null = null;
return $null;
}
[Edit See Also] Template:SeeAlso:JModel/getTable
Examples
<CodeExamplesForm />