From 5c4c1c2cd5beca8e335354093d28b36829210db5 Mon Sep 17 00:00:00 2001 From: Peter Goodhall Date: Tue, 9 Sep 2025 14:21:21 +0100 Subject: [PATCH] Fix SQL JOIN in get_last_qsos for station_profile Changed the SQL query in get_last_qsos to use LEFT JOIN for station_profile instead of JOIN. This ensures that QSOs are returned even if there is no matching station_profile, improving data completeness. --- application/models/Logbook_model.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index c00b2327..f66dff65 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -1932,7 +1932,6 @@ class Logbook_model extends CI_Model function get_last_qsos($num, $StationLocationsArray = null) { - if ($StationLocationsArray == null) { $CI = &get_instance(); $CI->load->model('logbooks_model'); @@ -1945,13 +1944,13 @@ class Logbook_model extends CI_Model $location_list = "'" . implode("','", $logbooks_locations_array) . "'"; $sql = "SELECT * FROM ( select * from " . $this->config->item('table_name') . " - WHERE station_id IN(" . $location_list . ") - order by col_time_on desc, col_primary_key desc - limit " . $num . + WHERE station_id IN(" . $location_list . ") + order by col_time_on desc, col_primary_key desc + limit " . $num . ") hrd - JOIN station_profile ON station_profile.station_id = hrd.station_id - LEFT JOIN dxcc_entities ON hrd.col_dxcc = dxcc_entities.adif - order by col_time_on desc, col_primary_key desc"; + LEFT JOIN station_profile ON station_profile.station_id = hrd.station_id + LEFT JOIN dxcc_entities ON hrd.col_dxcc = dxcc_entities.adif + order by col_time_on desc, col_primary_key desc"; $query = $this->db->query($sql);