首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Codeigniter join返回最后一个id

Codeigniter join返回最后一个id
EN

Stack Overflow用户
提问于 2019-01-05 00:00:33
回答 2查看 60关注 0票数 3

我想从我的表'device_id‘中获取id,但我一直从'inventory’中获取id,因为它是最后一个连接。

我试图在互联网上查找它,但可以找到Codeigniter的解决方案。

代码语言:javascript
复制
$this->db->where('device_id', $this->input->get('device_id'));

$this->db->join('repair_components', 'repair_options.component_id = repair_components.id');

$this->db->join('products', 'repair_options.product_id = products.id');

$this->db->join('inventory', 'repair_options.product_id = inventory.product_id', 'left');

$query = $this->db->get('repair_options');
$this->data['options'] = $query->result();

print_r($this->data['options']);

我想要数组‘$this->data’‘options’‘中'device_id’中的id。

EN

Stack Overflow用户

发布于 2019-01-05 01:42:38

表名赋予where子句中的列,并确保$this->input->get('device_id')在其中具有值。

代码语言:javascript
复制
$this->db->join('repair_components', 'repair_options.component_id = repair_components.id');
$this->db->join('products', 'repair_options.product_id = products.id');
$this->db->join('inventory', 'repair_options.product_id = inventory.product_id', 'left');
$this->db->where('table_name.device_id', $this->input->get('device_id'));
$query = $this->db->get('repair_options');
$this->data['options'] = $query->result();

print_r($this->data['options']);
票数 0
EN
查看全部 2 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54042330

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档