0

May be you have some idea how I can escape `$this->lang'. This is my actual query:

$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);

I can't use where clause because I get less output rows:

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

I need something like $this->db->join_on('info.lang', $this->lang); but in codeigniter I can't find something like this

2
  • Why you have added two and in your join statement? I.e 'info.id=p.id and and info.name=\'good\' info.lang=' Commented Jul 15, 2016 at 5:56
  • updated :p it's example only, this code wasn't tested. I wanted to show my problem as easy as possible Commented Jul 15, 2016 at 7:08

1 Answer 1

0

Try this query:

$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']);
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.