CodeigniteR语言 查询生成器,左连接,'on clause'中未准备好的PHP变量


也许

你知道我怎么能逃脱'$this->lang'。这是我的实际查询:

$this->db->select('p.id, p.photo, p.desc, info.desc');
$this->db->from('products as p');
$this->db->join('lang_info as info', 'info.id=p.id and info.name='good' info.lang='.$this->lang, 'left');
$this->db->join('lang_info as info2', 'info2.id=p.id and and info2.name='bad' info2.lang='.$this->lang, 'left');
$this->db->where('p.id', $this->product_id);

我不能使用where子句,因为我得到的输出行更少:

$this->db->where('info.lang', $this->lang);
$this->db->where('info2.lang', $this->lang);

我需要类似$this->db->join_on('info.lang', $this->lang);的东西,但在代码点火器中我找不到这样的东西

尝试以下查询:

$this->db->select('p.id, p.photo, p.desc, info.desc');
$this->db->from('products as p');
$this->db->join('lang_info as info', 'info.id=p.id and info.lang='.$this->lang, 'left');
$this->db->where('p.id', $this->product_id);
$this->db->where_in('info.name', ['good', 'bad']);

最新更新