Changeset 59 for branches/mvc/Application/Model/Measure.php
- Timestamp:
- Mar 1, 2015, 12:43:56 PM (10 years ago)
- Location:
- branches/mvc
- Files:
-
- 1 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/mvc/Application/Model/Measure.php
r47 r59 41 41 } 42 42 43 44 43 function AddValue($Value = array('Min' => 0, 'Avg' => 0, 'Max' => 0), $Level = 0, $Time = 0) 45 44 { … … 48 47 //echo(TimeToMysqlDateTime($Time).'|'.$Level."\n"); 49 48 50 $Result = $this->Database->select($this->Data['DataTable'], '*', 'Measure='.$this->Data['Id'].' AND Level='.$Level.' ORDER BY Time DESC LIMIT 2'); 49 $Result = $this->Database->select($this->Data['DataTable'], '*', '(Measure='.$this->Data['Id'].') AND '. 50 '(Level='.$Level.') ORDER BY Time DESC LIMIT 2'); 51 51 //echo($Database->LastQuery."\n"); 52 52 if($Result->num_rows == 0) 53 53 { 54 $this->Database->insert($this->Data['DataTable'], array('Min' => $Value['Min'], 'Avg' => $Value['Avg'], 'Max' => $Value['Max'], 'Level' => $Level, 'Measure' => $this->Data['Id'], 'Time' => $this->Database->TimeToMysqlDateTime($Time), 'Continuity' => 0)); 54 $this->Database->insert($this->Data['DataTable'], array('Min' => $Value['Min'], 55 'Avg' => $Value['Avg'], 'Max' => $Value['Max'], 'Level' => $Level, 56 'Measure' => $this->Data['Id'], 'Time' => $this->Database->TimeToMysqlDateTime($Time), 'Continuity' => 0)); 55 57 //echo($Database->LastQuery."\n"); 56 58 } else if($Result->num_rows == 1) 57 59 { 58 $this->Database->insert($this->Data['DataTable'], array('Min' => $Value['Min'], 'Avg' => $Value['Avg'], 'Max' => $Value['Max'], 'Level' => $Level, 'Measure' => $this->Data['Id'], 'Time' => $this->Database->TimeToMysqlDateTime($Time), 'Continuity' => 1)); 60 $this->Database->insert($this->Data['DataTable'], array('Min' => $Value['Min'], 61 'Avg' => $Value['Avg'], 'Max' => $Value['Max'], 'Level' => $Level, 62 'Measure' => $this->Data['Id'], 'Time' => $this->Database->TimeToMysqlDateTime($Time), 'Continuity' => 1)); 59 63 //echo($Database->LastQuery."\n"); 60 64 } else … … 71 75 else $Continuity = 0; 72 76 echo('('.$LastValue['Avg'].'=='.$NextToLastValue['Avg'].') and ('.$LastValue['Avg'].' == '.$Value.') and ('.$LastValue['Continuity'].' == 1) and ('.$Continuity.' == 1))'."\n"); 73 if(($LastValue['Min'] == $NextToLastValue['Min']) and ($LastValue['Min'] == $Value['Min']) and ($LastValue['Avg'] == $NextToLastValue['Avg']) and ($LastValue['Avg'] == $Value['Avg']) and ($LastValue['Max'] == $NextToLastValue['Max']) and ($LastValue['Max'] == $Value['Max']) and ($LastValue['Continuity'] == 1) and ($Continuity == 1)) 74 { 75 $this->Database->update($this->Data['DataTable'], '(Time="'.$LastValue['Time'].'") AND (Level='.$Level.') AND (Measure='.$this->Data['Id'].')', array('Time' => $this->Database->TimeToMysqlDateTime($Time))); 77 if(($LastValue['Min'] == $NextToLastValue['Min']) and ($LastValue['Min'] == $Value['Min']) and 78 ($LastValue['Avg'] == $NextToLastValue['Avg']) and ($LastValue['Avg'] == $Value['Avg']) and 79 ($LastValue['Max'] == $NextToLastValue['Max']) and ($LastValue['Max'] == $Value['Max']) and 80 ($LastValue['Continuity'] == 1) and ($Continuity == 1)) 81 { 82 $this->Database->update($this->Data['DataTable'], '(Time="'.$LastValue['Time'].'") '. 83 'AND (Level='.$Level.') AND (Measure='.$this->Data['Id'].')', array( 84 'Time' => $this->Database->TimeToMysqlDateTime($Time))); 76 85 //echo($this->Database->LastQuery."\n"); 77 86 } else 78 87 { 79 $this->Database->insert($this->Data['DataTable'], array('Min' => $Value['Min'], 'Avg' => $Value['Avg'], 'Max' => $Value['Max'], 'Level' => $Level, 'Measure' => $this->Data['Id'], 'Time' => $this->Database->TimeToMysqlDateTime($Time), 'Continuity' => $Continuity)); 88 $this->Database->insert($this->Data['DataTable'], array('Min' => $Value['Min'], 89 'Avg' => $Value['Avg'], 'Max' => $Value['Max'], 'Level' => $Level, 90 'Measure' => $this->Data['Id'], 'Time' => $this->Database->TimeToMysqlDateTime($Time), 91 'Continuity' => $Continuity)); 80 92 } 81 93 }
Note:
See TracChangeset
for help on using the changeset viewer.