[eluser]Unknown[/eluser]
Hi guys,
I need to write this sql in CI:
Code:
SELECT * FROM product WHERE
`producer_id` = '1' AND
(`name` LIKE '%q%' OR `content` LIKE '%q%' )
ORDER BY `name` asc LIMIT 2
as you see, I have data from search-form with 2 variables - producer_id and q (some searched value).
If I use this code, I get sql command without brackets (and that´s wrong):
Code:
$this->db->where('producer_id', $search['producer_id']);
$this->db->or_where('name LIKE', $search['q']);
$this->db->or_where('content LIKE', $search['q']);
$this->db->order_by('name', 'asc')->get('product', $limit, $offset)->result_array();
Code:
SELECT * FROM product WHERE
`producer_id` = '1' AND
`name` LIKE '%q%' OR `content` LIKE '%q%'
ORDER BY `name` asc LIMIT 2
do you have any suggestions how to do this?
thank you