JTableNested/check: Difference between revisions
From Joomla! Documentation
New page: ===Description===
Asset that the nested set data is valid.
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>Edit Descripton<nowik... |
m preparing for archive only |
||
| (One intermediate revision by the same user not shown) | |||
| Line 2: | Line 2: | ||
Asset that the nested set data is valid. | Asset that the nested set data is valid. | ||
===Syntax=== | ===Syntax=== | ||
| Line 48: | Line 46: | ||
</source> | </source> | ||
===Examples=== | ===Examples=== | ||
=== Code Examples === | |||
<dpl> | <dpl> | ||
noresultsheader=\n | noresultsheader=\n | ||
category=check | category=check | ||
category=JTableNested | category=JTableNested | ||
namespace=CodeExample | |||
category=MethodExample | category=MethodExample | ||
include=* | include=* | ||
format= ,,, | format= ,,, | ||
</dpl> | </dpl> | ||
Latest revision as of 02:11, 25 March 2017
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