JTable/save
From Joomla! Documentation
< JTable
| This recently added article requires a review |
Contents |
Syntax
boolean save ($source, $order_filter='', $ignore='')
Parameters
| Argument | Data type | Description | Default |
|---|---|---|---|
| $source | array | Source array for binding to class vars. See JTable/bind. | |
| $order_filter | string | Filter for the order updating. See JTable/reorder | '' |
| $ignore | mixed | An array or space separated list of fields not to bind. See JTable/bind. | '' |
Returns
TRUE if completely successful, FALSE if partially or not succesful.
Description
JTable::save() - Combines several methods of the JTable Class.
- Triggers the bind() method of the object, and binds the
$sourcearray to the object. See JTable/bind - Triggers the check() method of the object, and checks if all properties which have been previously been bound to the object are valid. See JTable/check
- Triggers the store() method of the object, and updates the row defined by the table key, or inserts a new record if the value of the table key equals 0. See JTable/store
- Triggers the checkin() method of the object (only if the table has the columns
checked_outandchecked_out_time). See JTable/checkin - If the
$order_filterparameter is set, the reorder() method is triggered, compacting the ordering sequence of the selected records. The parameter$order_filteris used to create the$whereparameter for theJTable::reorder($where='')method. See JTable/reorder
Preconditions
JTable is an abstract class. You need to write a child class, to use its functionality. See Part 4 of the MVC Tutorial
Source Code
In this particular case a look on the source code is much more self-explainatory than any example.
function save( $source, $order_filter='', $ignore='' ) { if (!$this->bind( $source, $ignore )) { return false; } if (!$this->check()) { return false; } if (!$this->store()) { return false; } if (!$this->checkin()) { return false; } if ($order_filter) { $filter_value = $this->$order_filter; $this->reorder( $order_filter ? $this->_db->nameQuote( $order_filter ).' = '.$this->_db->Quote( $filter_value ) : '' ); } $this->setError(''); return true; }
