[eluser]Michael Wales[/eluser]
You can do it in the model if it works for you.
Personally, I like to easily know what's happening in my controller/view. Using this method it's a bit more difficult to do that - you just echo out whatever the mode returns in your view.
I usually do something like this, so I know whether the model's method was successful or failed:
Model
Code:
function get_all_categories()
{
$this->db->select('id, name, description, position');
$query = $this->db->get('categories');
if($query->num_rows > 0){
return $query->result();
} else {
return FALSE;
}
Controller:
Code:
function whatever() {
$this->data->categories = $this->blogmodel->get_all_categories();
$this->load->view('view', $this->data);
View:
Code:
if ($categories) {
// Do Stuff
} else {
// My model method failed... do something else
}
It leads to a bit more typing but you also have a bit more control. I guess you could do something similar by checking to see if the name variable was your error message
Code:
if ($categories->name = 'Nog geen categorieën toegevoegd') {
// My method failed
}