From c4fce885092c3084486b5bf85344fd1fa24a642b Mon Sep 17 00:00:00 2001 From: Karsten Heiken Date: Fri, 22 Apr 2011 01:28:34 +0200 Subject: [PATCH] Move getting of a project to the model --- application/controllers/projects.php | 4 ++-- application/models/project.php | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/application/controllers/projects.php b/application/controllers/projects.php index e897d6a..2735759 100644 --- a/application/controllers/projects.php +++ b/application/controllers/projects.php @@ -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)); } /** diff --git a/application/models/project.php b/application/models/project.php index cee6f53..8fe4f0d 100644 --- a/application/models/project.php +++ b/application/models/project.php @@ -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.