diff --git a/application/controllers/api.php b/application/controllers/api.php index 71efc053..5a2ccc71 100644 --- a/application/controllers/api.php +++ b/application/controllers/api.php @@ -2,6 +2,33 @@ class API extends CI_Controller { + /* + TODOs + - Search Callsign (Return Json) + - Add QSO return json + */ + + + function search_callsign($callsign) { + $this->db->select('COL_PRIMARY_KEY, COL_CALL, COL_MODE, COL_BAND, COL_COUNTRY, COL_FREQ, COL_GRIDSQUARE, COL_RST_RCVD, COL_RST_SENT, COL_SAT_MODE, COL_SAT_NAME, COL_TIME_ON'); + $this->db->select("DATE_FORMAT(COL_TIME_ON, '%H:%i') AS time_on", FALSE ); + $this->db->select("DATE_FORMAT(COL_TIME_ON, '%d/%c/%Y') AS date_on", FALSE ); + $this->db->like('COL_CALL', $callsign); + $this->db->or_like('COL_GRIDSQUARE', $callsign); + $query = $this->db->get($this->config->item('table_name')); + + + $results = array(); + + foreach ($query->result() as $result) + { + $results [] = $result; + } + + echo json_encode($results); + + } + // Do absolutely nothing function index() {