Actions

API16

JTableNested/check

< API16:JTableNested
Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

Description

Asset that the nested set data is valid.



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;
}



Examples

Code Examples


Advertisement