php - How can I get the all value in one column using result() -


model:

function get_all() {         $query = $this->db->get('loan');         return $query->result();     }      function get_loan_name($code) {         $this->db->where('loan_type_code',$code);         $query = $this->db->get("loan_type");         return $query->row();     } 

controller:

function index() {     $this->data['loans'] = $this->loan_approval->get_all();     $this->build_view("loan_approval/list.php"); } 

in "loan table" have "loan_type_code" column want value in column , match 2nd function. example

loan table                             loan type table  id     loan_type           id     loan_type_code   loan_type_name  1         edl              1           edl          education loan  2         df               2           df            damayan fund 

i need match "loan_type" in table "loan" "loan_type_code" in "loan type" table. im thinking if of query "$this->controler->get_loan_name($this->data['loans']->loan_type);" not working.

why not doing @ db level using join?

$query = $this->db->select('loan.*, loan_type.loan_type_name')                   ->from('loan')                   ->join('loan_type','loan.loan_type = loan_type.loan_type_code')                   ->get(); return $query->result(); 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -