[eluser]lawrencesilva[/eluser]
hi guys im having some trouble with a MYSQL query when using CI's ActiveRecord Class
Code:
Active Record code piece:
$this->db->select('customer.id,customer.pid,
customer.name,
customer.created_by,
customer.name as customer_name,
customer.notes,
customer_parent.name as parent_customer');
$this->db->like('customer_parent.name', $arr['name']);
$this->db->or_like('customer.name', $arr['name']);
$this->db->or_like('customer.notes', $arr['name']);
$this->db->where('customer.is_parent',0);
$this->db->where('customer.active',1);
Code:
actual piece of MYSQL code output from the code above:
WHERE
`customer_parent`.`name` LIKE '%%' OR
`customer`.`name` LIKE '%%' OR
`customer`.`notes` LIKE '%%' AND
`customer`.`active` = 1 AND `customer`.`is_parent` = 0
Code:
preferred piece of MYSQL code output:
WHERE
(`customer_parent`.`name` LIKE '%%' OR
`customer`.`name` LIKE '%%' OR
`customer`.`notes` LIKE '%%') AND
`customer`.`active` = 1 AND
`customer`.`is_parent` = 0
i cant seem to put a parenthesis on the 'like' part for me to get my desired output...
any ideas guys? i just wanted to put a parenthesis and bind the lines: $this->db->like('customer_parent.name', $arr['name']);
$this->db->or_like('customer.name', $arr['name']);
$this->db->or_like('customer.notes', $arr['name']);
all together.
Thank you