метод для нахождения родительской категории:
Код:
function getParent($categoryID, $level=1)
{
if($level < 1)
{
return -1;
}
$db = new MySql(null, "mport4", null, null);
$db->MySql_Connect();
$db->MySql_SelectDb();
$selectQuery = "select * from categories _categories, categories
where _categories.cat_ID=" .$categoryID .
" AND _categories.cat_LEFT BETWEEN categories.cat_LEFT and categories.cat_RIGHT" .
" AND categories.cat_LEVEL=_categories.cat_LEVEL-" . (int)$level;
$db->MySql_QueryDb($selectQuery);
if ($db->dbResult != null)
{
while($row = mysql_fetch_assoc($db->dbResult))
{
$this->nodeInfo["id"] = $row["cat_ID"];
$this->nodeInfo["left"] = $row["cat_LEFT"];
$this->nodeInfo["right"] = $row["cat_RIGHT"];
$this->nodeInfo["level"] = $row["cat_LEVEL"];
$this->nodeInfo["data"]["title"] = $row["cat_TITLE"];
$this->nodeInfo["data"]["creation_date"] = $row["cat_CREATION_DATE"];
$this->nodeInfo["data"]["modify_date"] = $row["cat_MODIFY_DATE"];
$this->nodeInfo["data"]["desc"] = $row["cat_DESC"];
$this->nodeInfo["data"]["photo"] = $row["cat_PHOTO_PATH"];
}
return 0;
}
return -1;
}