I have the following code:
$this->db->from('addresses'); $this->db->where('user_id', $this->session->userdata('user.id')); $this->db->like('country', $pSearch); $this->db->or_like('state', $pSearch); $this->db->or_like('city', $pSearch); $this->db->or_like('zip', $pSearch);
which generates the following SQL
SELECT * FROM (`addresses`) WHERE `user_id` = '1' AND `country` LIKE '%d%' OR `state` LIKE '%d%' OR `city` LIKE '%d%' OR `zip` LIKE '%d%' ORDER BY `country` asc LIMIT 15
Is there a way to get it to generate it like this:
SELECT * FROM (`addresses`) WHERE `user_id` = '1' AND (`country` LIKE '%d%' OR `state` LIKE '%d%' OR `city` LIKE '%d%' OR `zip` LIKE '%d%') ORDER BY `country` asc LIMIT 15
As I want to get only entries for user_id = 1, not for all users.
source share