如何将 codeigniter 中的两个表与 jquery 数据表连接起来



这是我正在使用的代码,但它不起作用:我的联合查询没问题,我在没有 jquery 数据表的简单控制器上测试它并且它可以工作,但在联合中我无法从第二个表中获取数据以显示在编辑模式上

//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();
            }

检查 当通过jquery传递给控制器时,$ID_Student 不为空。

update:使用简单内部联接而不是左外部联接从两个表中获取数据匹配。

我为数据表创建了一个代码点火器模型。

也许这可以帮助您,请查看 https://github.com/moellmaster/codeigniter-datatables

最新更新