Actions

Difference between revisions of "JTable/load"

From Joomla! Documentation

(New page: {{review}} ===Syntax=== ''void'' move ($dirn, [$where = '']) === Parameters === {| class="wikitable" !Argument !Data type !Description !Default |- |$oid |integer |Optional primary key...)
 
Line 1: Line 1:
 
{{review}}
 
{{review}}
 
===Syntax===
 
===Syntax===
''void''  move ($dirn, [$where = ''])  
+
''void''  load ($oid = NULL)  
  
 
=== Parameters ===
 
=== Parameters ===
Line 22: Line 22:
 
JTable::load() - Loads a row from the database and binds the fields to the object properties.
 
JTable::load() - Loads a row from the database and binds the fields to the object properties.
 
===Example===
 
===Example===
coming soon...
+
Let's say we have a table, that stores greetings of different languages:
 +
{| class="wikitable"
 +
!id
 +
!greeting
 +
!language
 +
|-
 +
|1
 +
|Hello
 +
|English
 +
|-
 +
|2
 +
|Bonjour
 +
|French
 +
|-
 +
|3
 +
|Guten Tag
 +
|German
 +
|}
 +
 
 +
If we'd like to load the record with the id #3, we can do the following in a Controller or Model Class:
 +
<source lang="php">
 +
$table = $this->getTable('greeting');
 +
$table->load(3);
 +
echo '<pre>';
 +
print_r($table);
 +
echo '</pre>';
 +
</source>
  
 
===See also===
 
===See also===
 
* [[JTable/reorder]]
 
* [[JTable/reorder]]
 
<noinclude>[[Category:Development]][[Category:Framework]][[Category:JTable]]</noinclude>
 
<noinclude>[[Category:Development]][[Category:Framework]][[Category:JTable]]</noinclude>

Revision as of 16:41, 11 November 2008

Copyedit.png
This Article Needs Your Help

This article is tagged because it NEEDS REVIEW. You can help the Joomla! Documentation Wiki by contributing to it.
More pages that need help similar to this one are here. NOTE-If you feel the need is satistified, please remove this notice.


Contents

Syntax

void load ($oid = NULL)

Parameters

Argument Data type Description Default
$oid integer Optional primary key. If not specifed, the value of current key is used. NULL

Returns

nothing

Description

JTable::load() - Loads a row from the database and binds the fields to the object properties.

Example

Let's say we have a table, that stores greetings of different languages:

id greeting language
1 Hello English
2 Bonjour French
3 Guten Tag German

If we'd like to load the record with the id #3, we can do the following in a Controller or Model Class:

$table = $this->getTable('greeting');
$table->load(3);
echo '<pre>';
print_r($table);
echo '</pre>';

See also