diff --git a/application/controllers/configurations.php b/application/controllers/configurations.php new file mode 100644 index 0000000..a0a4f1c --- /dev/null +++ b/application/controllers/configurations.php @@ -0,0 +1,46 @@ +load->model('configuration'); + + // load language file + // $this->lang->load(strtolower($this->router->class)); + } + + /** + * Get a specific configuration from the database. + * + * @param string $config_id The configuration id to get. + */ + public function get($config_id) { + $configs = $this->configuration->get($config_id); + + $this->output + ->set_content_type('application/json') + ->set_output(json_encode($configs)); + } + + /** + * Search for a specific configuration and return a list of possible results. + * + * @param string $project The project in which to search for a configuration. + * @param string $needle The needle to look for in the haystack. + */ + public function search($project, $needle) { + $results = $this->configuration->search($project, $needle); + $this->output + ->set_content_type('application/json') + ->set_output(json_encode(array('count' => count($results), 'results' => $results))); + } +} \ No newline at end of file diff --git a/application/models/configuration.php b/application/models/configuration.php new file mode 100644 index 0000000..4270301 --- /dev/null +++ b/application/models/configuration.php @@ -0,0 +1,34 @@ +db->get_where('configurations', array('id' => $configuration_id)); + + return $query->row_array(); + } + + /** + * Search for a specific configuration and return a list of possible results. + * + * @param string $needle The needle to look for in the haystack. + */ + public function search($project, $needle) { + $query = $this->db->where('project_id', $project) + ->like('name', $needle)->get('configurations'); + $results = $query->result_array(); + + return $results; + } +} \ No newline at end of file