API16

JTable/save

From Joomla! Documentation

< API16:JTable
Revision as of 17:41, 22 March 2010 by Doxiki (talk | contribs) (New page: ===Description=== Method to provide a shortcut to binding, checking and storing a JTable instance to the database table. The method will check a row in once the data has been stored and i...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The "API16" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Description[edit]

Method to provide a shortcut to binding, checking and storing a JTable instance to the database table. The method will check a row in once the data has been stored and if an ordering filter is present will attempt to reorder the table rows based on the filter. The ordering filter is an instance property name. The rows that will be reordered are those whose value matches the JTable instance for the property specified.

[Edit Descripton]

Template:Description:JTable/save

Syntax[edit]

save($src, $orderingFilter= '', $ignore= '')
Parameter Name Default Value Description
$src An associative array or object to bind to the instance.
$orderingFilter Filter for the order updating
$ignore An optional array or space separated list of properties to ignore while binding.

Returns[edit]

boolean True on success.

Defined in[edit]

libraries/joomla/database/table.php

Importing[edit]

jimport( 'joomla.database.table' );

Source Body[edit]

public function save($src, $orderingFilter = '', $ignore = '')
{
        // Attempt to bind the source to the instance.
        if (!$this->bind($src, $ignore)) {
                return false;
        }

        // Run any sanity checks on the instance and verify that it is ready for storage.
        if (!$this->check()) {
                return false;
        }

        // Attempt to store the properties to the database table.
        if (!$this->store()) {
                return false;
        }

        // Attempt to check the row in, just in case it was checked out.
        if (!$this->checkin()) {
                return false;
        }

        // If an ordering filter is set, attempt reorder the rows in the table based on the filter and value.
        if ($orderingFilter) {
                $filterValue = $this->$orderingFilter;
                $this->reorder($orderingFilter ? $this->_db->nameQuote($orderingFilter).' = '.$this->_db->Quote($filterValue) : '');
        }

        // Set the error to empty and return true.
        $this->setError('');
        return true;
}

[Edit See Also] Template:SeeAlso:JTable/save

Examples[edit]

<CodeExamplesForm />