codeigniter - 在 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)在一个表中显示两个表
解决方案
解决方案 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();
推荐阅读
- javascript - 如何在html表单中排除少数输入
- c# - SignalR:空集线器脚本文件
- selenium - WebDriver 的 GetTitle() 方法不适用于 Frame Tag Doc
- excel - 每次刷新页面时循环更改特定单元格中字体颜色的范围
- sql - 重命名 Pivot 查询中的列名并将其时间值格式化为 HH:MM:SS 格式
- sql - 带有包含二进制数据的 WHERE 子句的 SQL 查询
- javascript - 循环块后Javascript json对象为空
- javascript - 无法访问使用 React.lazy 导入的组件的静态属性
- azure-api-management - APIM 处于消费模式 - 通过 /status-0123456789abcdef 获取 Azure APIM 运行状况检查返回“找不到资源”
- deep-learning - 在与图像翻译非常相似的任务中,如何处理 UNet 编码器/解码器 CNN 中的严重过拟合?