Update TLE in case they are null

This commit is contained in:
phl0
2026-01-20 10:23:23 +01:00
parent 17b00ffa95
commit 90695f19a8

View File

@@ -82,13 +82,22 @@ class Satellite_model extends CI_Model {
$tleline2 = trim($tlelines[1]);
}
$data = array(
'satelliteid' => $id,
'tle' => $tleline1 . "\n" . $tleline2,
);
$this->db->insert('tle', $data);
$insert_id = $this->db->insert_id();
return $insert_id;
$this->db->where('satelliteid', $id);
if ($this->db->get('tle')->num_rows() > 0) {
$data = array(
'tle' => $tleline1 . "\n" . $tleline2,
);
$this->db->where('satelliteid', $id);
$this->db->update('tle', $data);
} else {
$data = array(
'satelliteid' => $id,
'tle' => $tleline1 . "\n" . $tleline2,
);
$this->db->insert('tle', $data);
$insert_id = $this->db->insert_id();
return $insert_id;
}
}
function deleteSatMode($id) {