JTable/load

From Joomla! Documentation
< JTable(Difference between revisions)
Jump to: navigation, search
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.
 
=== Preconditions ===
 
=== Preconditions ===
JTable is an abstract class. You need to write a child class, to use its functionality. See [[Developing a Model-View-Controller Component - Part 4 - Creating an Administrator Interface#Creating the Table Class]]
+
JTable is an abstract class. You need to write a child class, to use its functionality. See [[Developing a Model-View-Controller Component - Part 4 - Creating an Administrator Interface#Creating the Table Class | Part 4 of the MVC Tutorial]]
  
 
===Example===
 
===Example===
Line 64: Line 64:
  
 
===See also===
 
===See also===
* [[JTable/reorder]]
+
* [[JTable/bind]]
 +
* [[Developing a Model-View-Controller Component - Part 4 - Creating an Administrator Interface#Creating the Table Class | Creating a JTable Child Class (MVC Tutorial Part 4)]]
 
<noinclude>[[Category:Development]][[Category:Framework]][[Category:JTable]]</noinclude>
 
<noinclude>[[Category:Development]][[Category:Framework]][[Category:JTable]]</noinclude>

Revision as of 17:03, 11 November 2008


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.

Preconditions

JTable is an abstract class. You need to write a child class, to use its functionality. See Part 4 of the MVC Tutorial

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 call the table object from within the model, and load the record:

$table = $this->getTable('greeting');
$table->load(3);
echo '<pre>';
print_r($table);
echo '</pre>';
 
/* RETURNS:
TableGreeting Object
(
    [id] => 3
    [greeting] => Guten Tag
    [language] => German
)
 
*/

See also

Personal tools
Namespaces

Variants
Actions
Navigation
Joomla! Sites
Toolbox