<?php
 $loopRecColumns = [ 'row_calculationName', ]; if (!array_intersect($availableTableColumns, $loopRecColumns)) { return ; } $recordsCountSQL = "SELECT COUNT(*) FROM `$reportTable`"; $recordsCount = $db->GetOne($recordsCountSQL); $groupSize = 500; for ($startGroup = 0; $startGroup < $recordsCount; $startGroup += $groupSize) { refreshReportStatus('processingRecords', 'loopResults', $startGroup/$recordsCount*100); $getRecordsListSQL = "SELECT * FROM `$reportTable` LIMIT ".$startGroup.", ".$groupSize; $recordsList = $db->GetAll($getRecordsListSQL); if ($db->ErrorNo()) killReport("Could not run SQL in report. SQL: ".$getServicesListSQL); foreach ($recordsList as $thisRow) { $updateColumns = []; if ($tableColumns['row_calculationName'] and $thisRow['row_serviceCode'] and $thisRow['row_locationCode'] and is_numeric($thisRow['row_calculationCode']) and $thisRow['row_calculationCode']>=0) { $updateColumns['row_calculationName'] = \App\Config\Services_Calculations::getInstance()->getServiceLocationCalculationName($thisRow['row_serviceCode'], $thisRow['row_locationCode'], $thisRow['row_calculationCode']); } if ($updateColumns) { $colsList = implode(', ', array_map(function($col){ return "`{$col}` = ?"; }, array_keys($updateColumns))); $updateRecordSQL = "UPDATE `$reportTable` SET {$colsList} WHERE row_internalId='".$thisRow['row_internalId']."'"; $updateRecordEx = $db->Execute($updateRecordSQL, array_values($updateColumns)); if ($db->ErrorNo()) { killReport("Could not run SQL in report. SQL: ".$updateRecordSQL); } } } } unset($recordsList); 