diff --git a/application/controllers/Api.php b/application/controllers/Api.php index 01af4ce4..664f7024 100644 --- a/application/controllers/Api.php +++ b/application/controllers/Api.php @@ -431,6 +431,12 @@ class API extends CI_Controller { } + function country_worked($dxcc_num, $band, $mode = NULL) { + $this->load->model('api_model'); + + echo $this->api_model->country_worked($dxcc_num, $band, $mode); + } + /* ENDPOINT for Rig Control */ diff --git a/application/models/Api_model.php b/application/models/Api_model.php index e0bcbbe3..2c11d633 100644 --- a/application/models/Api_model.php +++ b/application/models/Api_model.php @@ -38,6 +38,25 @@ class API_Model extends CI_Model { } + + function country_worked($dxcc_num, $band, $mode){ + + if($mode != NULL) { + $query = $this->db->query('SELECT COUNT(1) as count FROM '.$this->config->item('table_name').' WHERE COL_DXCC = "'.$dxcc_num.'" AND COL_BAND = "'.$band.'" AND COL_MODE = "'.$mode.'"'); + } else { + $query = $this->db->query('SELECT COUNT(1) as count FROM '.$this->config->item('table_name').' WHERE COL_DXCC = "'.$dxcc_num.'" AND COL_BAND = "'.$band.'"'); + } + + if ($query->num_rows() > 0) + { + foreach ($query->result() as $row) + { + return $row->count; + } + } + } + + function delete_key($key) { $this->db->where('key', $key); $this->db->delete('api');