I have a problem with use two like statement and where together:
$this->db->select('something');
$this->db->where('WHERE',$var);
$this->db->where_in('WHEREIN', $var);
$this->db->like('LIKE1',$query);
$this->db->or_like('LIKE2',$query);
$query = $this->db->get('table');
My query must select LIKE1 or LIKE2 where WHERE andWHEREIN is true.
If I use or_like, where statement get or too,
If i use just like, it's become like AND like statement
Any solution??
I found this solution:
use group_start() and group_end(), so my code turn to
$this->db->select('something');
$this->db->where('WHERE',$var);
$this->db->where_in('WHEREIN', $var);
$this->db->group_start();
$this->db->like('LIKE1',$query);
$this->db->or_like('LIKE2',$query);
$this->db->group_end();
$query = $this->db->get('table');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With