首页 > 解决方案 > 在 Codeigniter 中获取连接表的数据

问题描述

你能告诉我我的功能有什么问题吗

public function get_by(){
		$this->db->select('*');
        $this->db->from('filiere');
        $this->db->join('module', 'module.code_filiere = filiere.code_filiere');
        $query = $this->db->get();
	}

我想使用外键(code_fileiere)在一个表中显示两个表

标签: codeigniter

解决方案


解决方案 1:您需要为控制器返回数据

public function get_by(){
    $this->db->select('*');
    $this->db->from('filiere');
    $this->db->join('module', 'module.code_filiere = filiere.code_filiere');
    $query = $this->db->get();
    return $query->result();
}

在控制器中

$data = $this->your_model->get_by();

解决方案2:您需要为控制器返回数据

public function get_by(){
    $this->db->select('*');
    $this->db->from('filiere');
    $this->db->join('module', 'module.code_filiere = filiere.code_filiere');
    $query = $this->db->get();
    return $query;
}

在控制器中

$data = $this->your_model->get_by()->result();

从文档


推荐阅读