我想从我的表'device_id‘中获取id,但我一直从'inventory’中获取id,因为它是最后一个连接。
我试图在互联网上查找它,但可以找到Codeigniter的解决方案。
$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。
发布于 2019-01-05 01:42:38
将表名赋予where子句中的列,并确保$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');
$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']);https://stackoverflow.com/questions/54042330
复制相似问题