Welcome Guest, Not a member yet? Register   Sign In
Where should I store functions like...?
#1

[eluser]Carmichael[/eluser]
Hi CodeIgniters!

Where should I store functions like this

Code:
function get_username_by_id($id)
    {
        $q = $this->db->select('user_name')->get_where($this->users_table, array('user_id' => $id));
        
        if (!empty($q->row(0)->user_name))
        {
            return $q->row(0)->user_name;
        } else{
            return false;
        }
    }

I use that kind of functions in multiple controllers/views, so should I store that kind of functions in a helper or what?

I think it is more convenient to make such functions than to build big querys with joins.


Messages In This Thread
Where should I store functions like...? - by El Forum - 04-07-2012, 05:21 AM
Where should I store functions like...? - by El Forum - 04-07-2012, 08:24 AM
Where should I store functions like...? - by El Forum - 04-07-2012, 08:24 AM



Theme © iAndrew 2016 - Forum software by © MyBB