class ClassDBTree
extends ClassDBMySQL
{
private $DATA;
private $EOF;
public function __construct($dbHOST, $dbDATA, $dbUSER, $dbPASS) {
parent::__construct($dbHOST, $dbDATA, $dbUSER, $dbPASS);
$this->DATA = NULL;
$this->EOF = false;
}
private function SetNext() {
if ($this->DATA = $this->FetchSQL($this->
Query)) {
$this->EOF = false;
} else {
$this->EOF = true;
}
}
private function GetData() {
return $this->DATA;
}
private function fillArray(&$Node, $Level) {
$abbruch = false;
while (!$this->EOF && !$abbruch) {
$data = $this->GetData();
$id = $data['id'];
$Node[$id]['data'] = $data;
$this->SetNext();
$data = $this->GetData();
if ($data['Depth'] > $Level) {
$this->fillArray($Node[$id]['childs'], $Level+1);
}
if ($data['Depth'] < $Level) {
$abbruch = true;
}
}
}
public function GetArray($
SQL) {
$result = array();
$this->DATA = NULL;
$this->EOF = false;
$this->
Query = $this->OpenSQL($
SQL);
$this->SetNext();
$data = $this->GetData();
$this->fillArray($result, $data['Depth']);
$this->FreeSQL($this->
Query);
return $result;
}
}