Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5c4c1c2

Browse files
committed
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.
1 parent 3f8f813 commit 5c4c1c2

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

application/models/Logbook_model.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1932,7 +1932,6 @@ function get_station_id_with_webadif_api()
19321932

19331933
function get_last_qsos($num, $StationLocationsArray = null)
19341934
{
1935-
19361935
if ($StationLocationsArray == null) {
19371936
$CI = &get_instance();
19381937
$CI->load->model('logbooks_model');
@@ -1945,13 +1944,13 @@ function get_last_qsos($num, $StationLocationsArray = null)
19451944
$location_list = "'" . implode("','", $logbooks_locations_array) . "'";
19461945

19471946
$sql = "SELECT * FROM ( select * from " . $this->config->item('table_name') . "
1948-
WHERE station_id IN(" . $location_list . ")
1949-
order by col_time_on desc, col_primary_key desc
1950-
limit " . $num .
1947+
WHERE station_id IN(" . $location_list . ")
1948+
order by col_time_on desc, col_primary_key desc
1949+
limit " . $num .
19511950
") hrd
1952-
JOIN station_profile ON station_profile.station_id = hrd.station_id
1953-
LEFT JOIN dxcc_entities ON hrd.col_dxcc = dxcc_entities.adif
1954-
order by col_time_on desc, col_primary_key desc";
1951+
LEFT JOIN station_profile ON station_profile.station_id = hrd.station_id
1952+
LEFT JOIN dxcc_entities ON hrd.col_dxcc = dxcc_entities.adif
1953+
order by col_time_on desc, col_primary_key desc";
19551954

19561955
$query = $this->db->query($sql);
19571956

0 commit comments

Comments
 (0)