function migration() { global $DB; $ptsnmph = new PluginFusioninventorySnmphistory(); $sql_connection = "SELECT * FROM `glpi_plugin_fusioninventory_snmphistories`\n WHERE `Field`='0'\n ORDER BY `FK_process` DESC, `date_mod` DESC;"; $result_connection = $DB->query($sql_connection); while ($thread_connection = $DB->fetch_array($result_connection)) { $input = array(); $input['process_number'] = $thread_connection['FK_process']; $input['date'] = $thread_connection['date_mod']; if ($thread_connection["old_device_ID"] != "0" or $thread_connection["new_device_ID"] != "0") { if ($thread_connection["old_device_ID"] != "0") { // disconnection $input['creation'] = '0'; } else { if ($thread_connection["new_device_ID"] != "0") { // connection $input['creation'] = '1'; } } $input['FK_port_source'] = $thread_connection["FK_ports"]; if ($thread_connection["old_device_ID"] != "0") { $queryPort = "SELECT *\n FROM `glpi_networking_ports`\n WHERE `ifmac`='" . $thread_connection['old_value'] . "'\n LIMIT 0,1;"; $resultPort = $DB->query($queryPort); $dataPort = $DB->fetch_assoc($resultPort); } else { if ($thread_connection["new_device_ID"] != "0") { $queryPort = "SELECT *\n FROM `glpi_networking_ports`\n WHERE `ifmac`='" . $thread_connection['new_value'] . "'\n LIMIT 0,1;"; $resultPort = $DB->query($queryPort); $dataPort = $DB->fetch_assoc($resultPort); } } $input['FK_port_destination'] = $dataPort['ID']; $this->add($input); $ptsnmph->deleteFromDB($thread_connection['ID'], 1); } } }