Welcome Guest, Not a member yet? Register   Sign In
is this legal in a model?
#2

[eluser]xwero[/eluser]
If you return an array for that method why not returning an empty array.
Code:
function get_all_categories()
    {
        $this->db->select('id, name, description, position');
        $query = $this->db->get('categories');

        return ($query->num_rows > 0)? $query->result_array():array();
    }
For your question is it wrong, the short answer is no. I think it's even better than doing
Code:
function get_all_categories()
    {
        $this->db->select('id, name, description, position');
        $query = $this->db->get('categories');

        return ($query->num_rows > 0)? $query->result_array():false;
    }
Because then you haven't a consistent output.

It's up to the developer if he wants to do the first data manipulation in the model or in the controller.


Messages In This Thread
is this legal in a model? - by El Forum - 12-05-2007, 07:16 AM
is this legal in a model? - by El Forum - 12-05-2007, 07:25 AM
is this legal in a model? - by El Forum - 12-05-2007, 07:29 AM
is this legal in a model? - by El Forum - 12-05-2007, 07:40 AM
is this legal in a model? - by El Forum - 12-05-2007, 07:40 AM
is this legal in a model? - by El Forum - 12-05-2007, 11:08 AM



Theme © iAndrew 2016 - Forum software by © MyBB