else
{
throw_exception('未知$this->_id');
return
false;
}
}
/**
+----------------------------------------------------------
* 获取父节点,含直属父类(type=1),所有父类:type=0
* @access public
* @param $nodeId int 节点$this->_id
* @return $parentNode array()
+----------------------------------------------------------
*/
public
function
getParentNode(
$nodeId
,
$type
= 0)
{
if
(
$nodeId
== 0) throw_exception('未知$this->_id');;
$currentNode
=
$this
->getNodeById(
$nodeId
);
if
(
$currentNode
)
{
$condition
= " ".
$this
->_left.'<'.
$currentNode
[
$this
->_left].' and '.
$this
->_right.' >'.
$currentNode
[
$this
->_right]." ";
if
(
$type
==1)
//直属父类
{
return
$this
->where(
$condition
)->order(
$this
->_left." DESC")->limit(1)->find();
// $sql = "SELECT * FROM ".TABLE_NAME." WHERE {$condition} ORDER BY ".$this-
>_left." DESC LIMIT 1";
// return mysql_query($sql) or die(mysql_error());
}
else
if
(
$type
==0)
{
return
$this
->where(
$condition
)->findAll();
// $sql = "SELECT * FROM ".TABLE_NAME." WHERE {$condition} ";
// return mysql_query($sql) or die(mysql_error());
}
}
else
{
return
false;
}
}