早些时候抱歉,如果我的英语不好
首先我有像这样的变量
$data[code] = "xyz123";
$data[type] = "train";
和我在模型中写的查询
$this->db->select('*');
$this->db->from('table1');
$this->db->join('table2', 'table2.id = table1.id');
$this->db->select('table3', 'table3.id = table1.id AND table1.code LIKE $data[code] AND table1.type LIKE $data[type]');
但是当我尝试时,它不起作用,我认为我写的语法AND和LIKE是错误的。请有人知道解决方案吗?
谢谢你。
答案 0 :(得分:3)
我想你需要试试这个:
$this->db->select('table1.*,table2.*,table3.*');
$this->db->from('table1');
$this->db->join('table2', 'table2.id = table1.id');
$this->db->join('table3', 'table3.id = table1.id');
$this->db->like('table1.type', $data['type']);
$this->db->like('table1.code', $data['code']);
答案 1 :(得分:1)
尝试CI功能:
$this->db->like('type', $data['type']);
$this->db->like('code', $data['code']);
答案 2 :(得分:0)
$data["code"] = "xyz123";
$data["type"] = "train";
$this->db->select('*');
$this->db->from('table1');
$this->db->join('table2', 'table2.id = table1.id');
$this->db->select('table3', 'table3.id = table1.id AND table1.code LIKE '.$data["code"].' AND table1.type LIKE '.$data["type"].'');