API16

JTableAsset/check

From Joomla! Documentation

< API16:JTableAsset

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]

Asset that the nested set data is valid.



Syntax[edit]

check()


Returns[edit]

boolean True if the instance is sane and able to be stored in the database.

Defined in[edit]

libraries/joomla/database/table/asset.php

Importing[edit]

jimport( 'joomla.database.table.asset' );

Source Body[edit]

public function check()
{
        $this->parent_id = (int) $this->parent_id;

        // JTableNested does not allow parent_id = 0, override this.
        if ($this->parent_id > 0)
        {
                $this->_db->setQuery(
                        'SELECT COUNT(id)' .
                        ' FROM '.$this->_db->nameQuote($this->_tbl).
                        ' WHERE `id` = '.$this->parent_id
                );
                if ($this->_db->loadResult()) {
                        return true;
                }
                else
                {
                        if ($error = $this->_db->getErrorMsg()) {
                                $this->setError($error);
                        }
                        else {
                                $this->setError('JError_Invalid_parent_id');
                        }
                        return false;
                }
        }

        return true;
}



Examples[edit]

Code Examples[edit]