- Timestamp:
- Oct 2, 2019, 12:15:16 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/NetworkConfigRouterOS/Generators/NetwatchImport.php
r860 r861 43 43 44 44 $Queries = array(); 45 $QueriesInsert = array(); 46 $QueriesUpdate = array(); 45 47 foreach($Interfaces as $Index => $Interface) 46 48 { 47 49 // Update last online time if still online 48 50 if($Interface['NewOnline']) 49 $Queries[] = $this->Database->GetUpdate('NetworkInterface', '`Id` = "'.$Interface['Id'].'"',51 $Queries[] = $this->Database->GetUpdate('NetworkInterface', '`Id` = '.$Interface['Id'], 50 52 array('LastOnline' => TimeToMysqlDateTime($StartTime))); 51 53 … … 53 55 { 54 56 // Online state changed 55 $Queries [] = 'INSERT INTO `NetworkInterfaceUpDown` (`Interface`,56 `State`, `Time`, `Duration`) VALUES ('.$Interface['Id'].', '.$Interface['NewOnline'].', "'.57 $QueriesInsert[] = 'INSERT INTO `NetworkInterfaceUpDown` (`Interface`,'. 58 '`State`, `Time`, `Duration`) VALUES ('.$Interface['Id'].', '.$Interface['NewOnline'].', "'. 57 59 TimeToMysqlDateTime($StartTime).'", NULL)'; 58 60 // Update previous record duration in UpDown table 59 $Queries [] = 'UPDATE `NetworkInterfaceUpDown` AS `TM` SET `Duration` = TIMESTAMPDIFF(SECOND, '.61 $QueriesUpdate[] = 'UPDATE `NetworkInterfaceUpDown` AS `TM` SET `Duration` = TIMESTAMPDIFF(SECOND, '. 60 62 '`TM`.`Time`, (SELECT `Time` FROM (SELECT * FROM `NetworkInterfaceUpDown`) AS `TA` WHERE (`TA`.`Time` > `TM`.`Time`) '. 61 63 'AND (`TA`.`Interface`=`TM`.`Interface`) ORDER BY `TA`.`Time` ASC LIMIT 1)) '. … … 65 67 } 66 68 } 69 echo("transakce insert\n"); 70 $this->Database->Transaction($QueriesInsert); 71 echo("done\n"); 67 72 echo("transakce\n"); 68 73 $this->Database->Transaction($Queries); 74 echo("done\n"); 75 echo("transakce\n"); 76 $this->Database->Transaction($QueriesUpdate); 69 77 echo("done\n"); 70 78
Note:
See TracChangeset
for help on using the changeset viewer.