diff --git a/application/controllers/Gridsquares.php b/application/controllers/Gridsquares.php index bdd702d6..1e0d2755 100644 --- a/application/controllers/Gridsquares.php +++ b/application/controllers/Gridsquares.php @@ -53,7 +53,7 @@ class Gridsquares extends CI_Controller { $query = $this->gridsquares_model->get_confirmed_sat_squares(); - if ($query->num_rows() > 0) + if ($query && $query->num_rows() > 0) { foreach ($query->result() as $row) { @@ -88,7 +88,7 @@ class Gridsquares extends CI_Controller { // Get worked squares $query = $this->gridsquares_model->get_worked_sat_squares(); - if ($query->num_rows() > 0) + if ($query && $query->num_rows() > 0) { foreach ($query->result() as $row) { @@ -122,7 +122,7 @@ class Gridsquares extends CI_Controller { $query_vucc = $this->gridsquares_model->get_worked_sat_vucc_squares(); - if ($query_vucc->num_rows() > 0) + if ($query && $query_vucc->num_rows() > 0) { foreach ($query_vucc->result() as $row) { @@ -149,7 +149,7 @@ class Gridsquares extends CI_Controller { // Confirmed Squares $query_vucc = $this->gridsquares_model->get_confirmed_sat_vucc_squares(); - if ($query_vucc->num_rows() > 0) + if ($query && $query_vucc->num_rows() > 0) { foreach ($query_vucc->result() as $row) { @@ -225,7 +225,7 @@ class Gridsquares extends CI_Controller { $query = $this->gridsquares_model->get_band_confirmed($band); - if ($query->num_rows() > 0) + if ($query && $query->num_rows() > 0) { foreach ($query->result() as $row) { @@ -254,7 +254,7 @@ class Gridsquares extends CI_Controller { $query = $this->gridsquares_model->get_band($band); - if ($query->num_rows() > 0) + if ($query && $query->num_rows() > 0) { foreach ($query->result() as $row) { diff --git a/application/models/Gridsquares_model.php b/application/models/Gridsquares_model.php index 42914aad..537df547 100644 --- a/application/models/Gridsquares_model.php +++ b/application/models/Gridsquares_model.php @@ -7,6 +7,10 @@ class Gridsquares_model extends CI_Model { $CI->load->model('logbooks_model'); $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + if (!$logbooks_locations_array) { + return null; + } + $this->db->select('distinct substring(COL_GRIDSQUARE,1,6) as SAT_SQUARE, COL_SAT_NAME', FALSE); $this->db->where_in('station_id', $logbooks_locations_array); $this->db->where('COL_GRIDSQUARE !=', ''); @@ -20,6 +24,10 @@ class Gridsquares_model extends CI_Model { $CI->load->model('logbooks_model'); $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + if (!$logbooks_locations_array) { + return null; + } + $location_list = "'".implode("','",$logbooks_locations_array)."'"; $sql = 'SELECT distinct substring(COL_GRIDSQUARE,1,6) as SAT_SQUARE, COL_SAT_NAME FROM ' @@ -35,6 +43,10 @@ class Gridsquares_model extends CI_Model { $CI->load->model('logbooks_model'); $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + if (!$logbooks_locations_array) { + return null; + } + $location_list = "'".implode("','",$logbooks_locations_array)."'"; $sql = 'SELECT COL_VUCC_GRIDS, COL_SAT_NAME FROM ' @@ -49,6 +61,10 @@ class Gridsquares_model extends CI_Model { $CI->load->model('logbooks_model'); $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + if (!$logbooks_locations_array) { + return null; + } + $this->db->select('COL_PRIMARY_KEY, COL_VUCC_GRIDS, COL_SAT_NAME', FALSE); $this->db->where_in('station_id', $logbooks_locations_array); $this->db->where('COL_VUCC_GRIDS !=', ""); @@ -61,6 +77,9 @@ class Gridsquares_model extends CI_Model { $CI->load->model('logbooks_model'); $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + if (!$logbooks_locations_array) { + return null; + } $this->db->select('distinct substring(COL_GRIDSQUARE,1,6) as GRID_SQUARES, COL_BAND', FALSE); $this->db->where_in('station_id', $logbooks_locations_array); @@ -83,6 +102,10 @@ class Gridsquares_model extends CI_Model { $CI->load->model('logbooks_model'); $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + if (!$logbooks_locations_array) { + return null; + } + $location_list = "'".implode("','",$logbooks_locations_array)."'"; $sql = 'SELECT distinct substring(COL_GRIDSQUARE,1,6) as GRID_SQUARES, COL_BAND FROM '