1
0
Fork 0

Begin basic view functionality.

This commit is contained in:
Andrew Tomaka 2011-11-05 14:55:02 -04:00
parent 7f88eb83df
commit 3c5c19a712
2 changed files with 31 additions and 0 deletions

View File

@ -0,0 +1,20 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class View extends CI_Controller {
public function index() {
$this->load->model('fileupload');
$id = $this->uri->segment($this->uri->total_segments());
$total_uploads = $this->fileupload->count_uploads();
if($id == false || !is_numeric($id) || $id < 0 || $id > $total_uploads) {
exit('bad id');
}
$upload = $this->fileupload->get_upload($id);
$this->load->model('viewer');
print_r($upload);
}
}

View File

@ -15,6 +15,17 @@ class Fileupload extends CI_Model {
return $this->db->insert_id();
}
function count_uploads() {
return $this->db->count_all('uploads');
}
function get_upload($id) {
$this->db->select('extension, views, created')->from('uploads')->where('id',$id);
$query = $this->db->get();
return $query->result();
}
}
?>