PHP-Code:
<?php
class tree {
var $id = null;
var $subids = array();
function tree($id) {
$this->id = $id;
$this->_sqlGetSubids();
}
function _sqlGetSubids() {
$GLOBALS["db"]->query(" SELECT id FROM tree WHERE parentID=".$this->id);
$ids = array();
while($GLOBALS["db"]->next_record()) {
array_push($ids, $GLOBALS["db"]->getRecord("id");
}
foreach($ids as $value) {
$subids[$value] = new tree($value);
}
}
}
define("TREE_ROOT_ID",0);
$tree = new tree(TREE_ROOT_ID);
?>
PHP-Code:
<?php
foreach($ids as $value) {
$subids[$value] = new tree($value);
}
?>
Wie ist die genaue Bezeichnung für diese Art und Weise der Abarbeitung? Also eine Klasse die in sich eine Instanz von sich selbst erzeugt?
Kommentar