function getChildren() { $request = \Slim\Slim::getInstance()->request(); $firstName = $request->params('firstName'); $lastName = $request->params('lastName'); $child = null; if ($firstName == null && $lastName == null) { $child = fetchChildren(); } else { $child = fetchChildrenByName($firstName, $lastName); } }
function fetchChildren($contentid, $depth, $level = 0) { // this function is used by get children recursively global $arrChildIDs; // retrieve all children of $parent $sendParams = array(); $sql = "SELECT content.id FROM content WHERE parentid = :contentid"; $sendParams['contentid'] = $contentid; $result = queryDatabase($sql, $sendParams); while ($row = $result->fetch(PDO::FETCH_ASSOC)) { $arrChildIDs[] = $row['id']; if ($depth == -1) { fetchChildren($row['id'], $level + 1); } else { if ($level + 1 < $depth) { fetchChildren($row['id'], $level + 1); } } } }