在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将两个表放在一个表中。你能发布你的控制器方法并查看代码吗?请检查下面的提示