how to get value from another table with join code igniter how to get value from another table with join code igniter codeigniter codeigniter

how to get value from another table with join code igniter


You need to define which Join you are going to use like left, right, inner, outer

$this->db->join('kategori', 'kategori.id_kategori = artikel.id_kategori');replace with $this->db->join('kategori', 'kategori.id_kategori = artikel.id_kategori','left');


Please try this I hope there is problem in your code.

public function ambil($id = FALSE){        $select = ($id === FALSE) ? "artikel.*, kategori.kategori AS kategori" : "*";    $this->db->select($select);    $this->db->form('artikel');    if($id===FALSE){        $this->db->join('kategori', 'artikel.id_kategori = kategori.id_kategori', 'left'); // You need to define which Join you are going to use like left, right, inner, outer        return $this->db->get()->result_array();    }         return $this->db->get_where('artikel',array('id'=>$id))->row_array();}

If this did not work call my attention let me check another way of solving this problem. Thanks