Move getting of a project to the model

This commit is contained in:
Karsten Heiken
2011-04-22 01:28:34 +02:00
parent 32478703f6
commit c4fce88509
2 changed files with 14 additions and 2 deletions

View File

@@ -65,10 +65,10 @@ class Projects extends CI_Controller {
}
public function detail($projects, $area, $id) {
$result = $this->db->get_where('projects', array('id' => $id))->row_array();
$project = $this->project->get($id);
$this->output
->set_content_type('application/json')
->set_output(json_encode(array('result' => $result)));
->set_output(json_encode($project));
}
/**

View File

@@ -80,6 +80,18 @@ class Project extends CI_Model {
return $publicProjects;
}
/**
* Get a specific project from the database.
*
* @param type $project_id The project to get.
*/
public function get($project_id) {
$result = $this->db->get_where('projects', array('id' => $project_id))->row_array();
$this->db->query('UPDATE `projects` SET `lastaccess` = NOW() WHERE `id`='.$this->db->escape($project_id).';');
return $result;
}
/**
* Get all available configurations from a specific project.