Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

angularjs How can I write below code in better way to keep looping endlessly

if($DBObj->fetchNumOfRows() >= 1){
    $queryRecords = $DBObj->fetchAllRecordsArray();
    $rows = $DBObj->fetchNumOfRows();
    
    for($i = 0; $i < $rows; $i++){
        recursiveAction($queryRecords[$i]);
    }
}

function recursiveAction(&$item, $propertiesArray) {
    switch ($item['propof']) {
        case 'page':
            // No need for that "if" check
            $propertiesArray[$item['propofid']][] = [$item['propid'] => $item['propvalue'],'proplinkedto' => $item['proplinkedto']];

            break;
        case 'object':
            $DBObj->querySelect(...);
            $queryRecord = $DBObj->fetchNumOfRows() == 1 ? $DBObj->fetchRecordArray() : "";

            if (!empty($queryRecord)) {
                // Here we convert common part of "object" into recursion
                recursiveAction($queryRecord);
            }

            break;
      case 'element':
            ...
    }
}
 
PREVIOUS NEXT
Tagged: #angularjs #How #I #write #code #looping #endlessly
ADD COMMENT
Topic
Name
7+6 =