SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 98 | Next

James Kennard

"Mastering Joomla! 1.5 Extension and Framework Development"

We can
interrogate any data source. Data that we return using the get methods can be of any
type. Many of the core components return data in stdClass objects.
As well as accessing data, we use the model to modify data. In this example we
implement a save() method; this will act as a pass-through for the JTable class
TableFoobar save() method, which we defined in Chapter 3.
/**
* Save a foobar
*
* @param mixed object or associative array of data to save
* @return Boolean true on success
*/
function save($data)
{
???
???
Component Design
[ 74 ]
// get the table
$table =& $this->getTable('Foobar');
// save the data
if (!$table->save($data))
{
// an error occurred, update the model error message
$this->setError($table->getError());
return false;
}
return true;
}
In the example we use the getTable() method to retrieve an instance of the
TableFoobar class. We could have used the static JTable::getInstance() method
but this would have required more effort because it defaults to looking for core
JTable subclasses.


Pages:
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6