"; function getPolyHp($dataArray,$inParam) { unset($resVal);unset($tbArray); for($i=0; $i1) { $polynomial = new zc_math_polynomial($tbArray); $polynomial->calculate_coefficients(); $resVal = $polynomial->get_y($inParam); } else $resVal=0; return round($resVal,2); } function getPolyPe($dataArray,$inParam) { unset($resVal);unset($tbArray); for($i=0; $i1) { $polynomial = new zc_math_polynomial($tbArray); $polynomial->calculate_coefficients(); $resVal = $polynomial->get_y($inParam); } else $resVal=0; return round($resVal,2); } $tableName = 'softspm_his.rep_his_data_everyday_2014_q1'; unset($wellArray); $wellArray = sqlGetResAsArray("select * from ".$tableName." where RHD_Q_VAL>0 and (RHD_PE_VAL<0 or RHD_PE_VAL is null) limit 200"); for ($i=0; $i0 && strlen($wellExch[0]['WLE_ENG_NO'])>0) { $testIDArray = sqlGetResAsArray("select max(TST_ID) TST_ID from tst_tests where TST_PUP_SN_NO='".$wellExch[0]['WLE_PUMP_NO']."' and TST_ENG_SN_NO='".$wellExch[0]['WLE_ENG_NO']."' and TST_AUDIT_CD<='".$wellExch[0]['WLE_DATE_FROM']."'"); } unset($probaArray); unset($mocSP); if ($testIDArray[0]['TST_ID']>0) { $wynik = mysql_query("select TSD_VAL_04,TSD_VAL_08,TSD_VAL_14 from tst_tests left join tst_test_details on TSD_TST_ID=TST_ID where TST_ID=".$testIDArray[0]['TST_ID']." order by TSD_MSR_STEP"); if($wynik)while ($r = mysql_fetch_array($wynik)) { $probaArray[] = array( 'q' => (float) $r["TSD_VAL_04"], 'h' => (float) $r["TSD_VAL_08"], 'p' => (float) $r["TSD_VAL_14"] ); } $mocSP = (float) getPolyPe($probaArray,$wellArray[$i]['RHD_Q_VAL']); // if ($mocSP>0) { mysql_query("UPDATE ".$tableName." SET RHD_PE_VAL='".$mocSP."' WHERE RHD_ID=".$wellArray[$i]['RHD_ID']); echo("UPDATE ".$tableName." SET RHD_PE_VAL='".$mocSP."' WHERE RHD_ID=".$wellArray[$i]['RHD_ID']); echo'
'; } } else { unset($engArray); $engArray = sqlGetResAsArray("select * from seg_engines where ENG_NAME='".$wellExch[0]['WLE_ENG_NAME']."'"); if ($engArray[0]['ENG_POWER']>0) { mysql_query("UPDATE ".$tableName." SET RHD_PE_VAL='".$engArray[0]['ENG_POWER']."' WHERE RHD_ID=".$wellArray[$i]['RHD_ID']); echo("UPDATE ".$tableName." SET RHD_PE_VAL='".$engArray[0]['ENG_POWER']."' WHERE RHD_ID=".$wellArray[$i]['RHD_ID']); echo'
'; } } } echo"STOP: ".date('Y-m-d H:i:m')."
"; mysql_close($polacz);