API16

API16:JTableNested/check

From Joomla! Documentation

Revision as of 22:43, 22 March 2010 by Doxiki (talk | contribs) (New page: ===Description=== Asset that the nested set data is valid. <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>Edit Descripton<nowik...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Description

Asset that the nested set data is valid.

[Edit Descripton]

Template:Description:JTableNested/check

Syntax

check()


Returns

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

Defined in

libraries/joomla/database/tablenested.php

Importing

jimport( 'joomla.database.tablenested' );

Source Body

public function check()
{
        $this->parent_id = (int) $this->parent_id;
        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');
                        }
                }
        } else {
                $this->setError('JError_Invalid_parent_id');
        }

        return false;
}

[Edit See Also] Template:SeeAlso:JTableNested/check

Examples

<CodeExamplesForm />