Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Codeigniter中获取连接表的数据_Codeigniter - Fatal编程技术网

在Codeigniter中获取连接表的数据

在Codeigniter中获取连接表的数据,codeigniter,Codeigniter,你能告诉我我的功能有什么问题吗 公共函数get_by(){ $this->db->select('*'); $this->db->from('filiere'); $this->db->join('module','module.code_filiere=filiere.code_filiere'); $query=$this->db->get(); }解决方案1:您需要返回控制器的数据 public function get_by(){ $this->db->select

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

公共函数get_by(){
$this->db->select('*');
$this->db->from('filiere');
$this->db->join('module','module.code_filiere=filiere.code_filiere');
$query=$this->db->get();

}
解决方案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();
}
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();
$data = $this->your_model->get_by()->result();
解决方案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->result();
}
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();
$data = $this->your_model->get_by()->result();

函数中没有错误,但没有将捕获的值从函数返回到控制器

你应该使用

$query->result()
用于多值

$query->row()
用于单个值

从数据库

更新你的功能

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->num_rows() > 0) ? $query->result() : false;
}

唯一错误的是缺少信息……抱歉,我不够清楚。我想说的是,我有两个表格filiere(code_filiere,nom_filiere,Department)和module(code_module,nom_module,code_filiere)正如你所看到的,code_filiere是一个外键,我想使用带有codeigniter的Datatables将两个表放在一个表中。你能发布你的控制器方法并查看代码吗?请检查下面的提示