Select only one column from multiple rows in codeigniter. How to and is this more efficient? Select only one column from multiple rows in codeigniter. How to and is this more efficient? codeigniter codeigniter

Select only one column from multiple rows in codeigniter. How to and is this more efficient?


    $this->db->select('name');     $this->db->from('tblNAME');       $this->db->where('res_id', $res_id);    return $this->db->get()->result();

It is quicker and more efficient I suppose as you are not returning everything.

UNTESTED

Here is a tested function I use which you might find good reeference

function get($id = null)         {            $this->db->select('id, Username, First_Name, Last_Name, Role, Email');            $this->db->from('user');            if (!is_null($id)) $this->db->where('id', $id);            $this->db->order_by('id', 'desc');            return $this->db->get()->result();        }