найти весь путь от корня до категории:
Код:
function enumPath($categoryID, $showRoot=false)
{
$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";
if ($showRoot == false)
{
$selectQuery .= ' AND categories.cat_LEVEL>0 order by categories.cat_LEFT';
}
$db->MySql_QueryDb($selectQuery);
//echo $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"];
$this->nodeInfoCollection[] = $this->nodeInfo;
}
return 0;
}
return -1;
}