phpjquerycodeigniterdatatables

how to joint two table in codeigniter with jquery data table


this is the code i m using but it,s not working:my joint query is ok i test it on simple controller with out jquery datatable and it work,but in joint i can,t get data from second table to show on edit modal

//controller

        public function ajax_edit($ID_Student)
            {
                $data = $this->person->get_by_id($ID_Student);
                echo json_encode($data);
            }

    //mdel
        public function get_by_id($ID_Student)
            {
                $this->db->from($this->table);
                $this->db->where('ID_Student',$ID_Student);
                $this->db->join('section', 'student.sec_id = section.sec_id',
           'left outer'); 
                $query = $this->db->get();

                return $query->row();
            }

Solution

  • Check while passing to controller through jquery, $ID_Student is not empty.

    updated: Use simple inner join instead of left outer join to get data matching from both the tables.