JTable/load
出典: Joomla! ドキュメンテーション
| This recently added article requires a review |
目次 |
Syntax
void load ($keys = NULL,$reset = true)
Parameters
| Argument | Data type | Description | Default |
|---|---|---|---|
| $keys | mixed | An optional primary key value to load the row by, or an array of fields to match. | NULL |
| $reset | boolean | True to reset the default values before loading the new row. | NULL |
Returns
True if successful. False if row not found or on error (internal error state set in that case).
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
自動更新 2012/05/26 00:32:29
