Welcome Guest, Not a member yet? Register   Sign In
Passing arguments and conditions to model in codeigniter
#4

[eluser]Aken[/eluser]
For me, it would depend on how many of those arguments you end up using. Will your SELECT arguments vary that much throughout your application?

For me, models are designed to alleviate the many different variations you have of writing DB queries. They're meant to simplify the retrieval of data. I shouldn't have to add lots of parameters to my models, because then I'm just writing the queries individually again.

That said, if I found myself needing to add odd, specific arguments or conditions often, I probably would create a catch-all type model function like that. But only if the need arose. I'd prefer to keep my models specific.

Code:
// Specific function.
function getName($id)
{
    $q = $this->db->get_where('Names', array('name_id' => $id));

    return $q->row();
}


Messages In This Thread
Passing arguments and conditions to model in codeigniter - by El Forum - 05-08-2010, 02:20 PM



Theme © iAndrew 2016 - Forum software by © MyBB