Search
 
SCRIPT & CODE EXAMPLE
 

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':
            ...
    }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: angularjs Both outer and inner divs have ng-click and when I click on the inner div, both ng-clicks execute. How to prevent that 
Javascript :: Changing the value of a dropdown when the value of a number box changes in AngularJS 
Javascript :: angularjs How to pass option value and label created with ng-repeat triggered by ng-change 
Javascript :: angularjs promise .then() to run sequentially inside a for loop 
Javascript :: js read html file 
Javascript :: show user profile nodejs pug 
Javascript :: angularjs Separate values in select containing 2 object 
Javascript :: Wait for AngularJS Service to finish running 
Javascript :: How to merge array into JSON array 
Javascript :: How to pass React Native Component as a JSON object 
Javascript :: react table Maximum update depth exceeded. 
Javascript :: Undefined value document.getElementById 
Javascript :: how to add link during filter and mapping in javascript 
Javascript :: Store input values in array javascript 
Javascript :: Node.js and Express session handling - Back button problem 
Javascript :: sinalR 
Javascript :: react native push notifications cancel delivered notification 
Javascript :: bcrypt npm 
Javascript :: javascript get next month name 
Javascript :: create instance method javascript 
Javascript :: This Refers To The Window Object Here 
Javascript :: javascript ls 
Javascript :: javascript for website design center text 
Javascript :: Function Written In Constructor Involving A Promise, Can Be Accessed As Below 
Javascript :: javascript hide div 
Javascript :: react native webview get query params 
Javascript :: How to remove added values with javascript 
Javascript :: verify if user input is equal to javascript 
Javascript :: shrinkStringByRepeatFactor 
Javascript :: radio button remove checked 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =