function setChildDepth($parentID, $parentDepth) { /*****DEBUG****/ //error_log(" parentID = $parentID and parentDepth = $parentDepth"); $children = getChildTerms($parentID); /*****DEBUG****/ //error_log(" $parentID - children = ". print_r($children,true)); if (!$children) { // if no children nothing to do so return return; } $childIDList = join(",", array_keys($children)); /*****DEBUG****/ //error_log(" childID list = $childIDList"); $depth = $parentDepth + 1; // set every childs depth $query = "update defTerms set trm_Depth = " . $depth . " where trm_ID in(" . $childIDList . ")"; mysql_query($query); /*****DEBUG****/ //error_log("query = $query and errors ".mysql_error()); foreach ($children as $childID => $childCount) { if ($childCount) { setChildDepth($childID, $depth); } } }
function setChildDepth($parentID, $parentDepth) { $children = getChildTerms($parentID); if (!$children) { // if no children nothing to do so return return; } $childIDList = join(",", array_keys($children)); $depth = $parentDepth + 1; // set every childs depth $query = "update defTerms set trm_Depth = " . $depth . " where trm_ID in(" . $childIDList . ")"; mysql_query($query); foreach ($children as $childID => $childCount) { if ($childCount) { setChildDepth($childID, $depth); } } }