[eluser]Steve Grant[/eluser]
You could combine it within both the model and controller for extra safety.
For example, you have a function within a model that returns an array or object containing the article data, but returns null if it can't find an article that matches the ID provided.
Then within the controller, you can check the output to see if it's null. If it is null, output a suitable message or display an "error" view.
Model
Code:
function get_article($article_id)
{
$query = $this->db->get_where('articles', array('article_id', $article_id));
if($this->db->count_all_results() == 0)
{
return null;
}
else
{
return $query->row();
}
}
Controller
Code:
function view()
{
$data['article_data'] = $this->MyModel->get_article($this->uri->segment(3));
if($data['article_data'] == null)
{
$this->load->view('error');
}
else
{
$this->load->view('article/view', $data);
}
}
Something like that should do the trick.