What are the pros and cons of fetching the database and returning the query object or the result/result_array?
$query = $this->db->get('mytable');
return $query;
vs
$query = $this->db->get('mytable');
return $query->result; //or result_array()
I know that if you return the query object, it makes it flexible for the developer to fetch whatever type of resource she wants. But this could lead to more ambiguity in code design.
What is considered best practice?
I guess it depends on what you need to do with it, process it further or show it to the user. If simple the results have to be shown in the View, I’d rather return the result otherwise if more “complex” processing is needed you could return the query-object.