请帮我:
SELECT *
FROM `product`
WHERE `vi_name` LIKE '%product%'
OR `en_name` LIKE '%product%'
AND `parent_id` != 0
我写了我自己的代码,但它仍然计算行的一些方式有 parent_id = 0
function get_product_by_search_slug($slug) {
$this -> db -> from('product');
$this -> db -> like('vi_name', $slug);
$this -> db -> or_like('en_name', $slug);
$this -> db -> where_not_in('parent_id', 0);
$query = $this -> db -> get();
return $query -> result();
}
我得到了一个解决方案,它工作正常,但不知何故我对它不太满意:
function get_product_by_search_slug($slug) {
$this -> db -> select("* FROM `product` WHERE `vi_name` LIKE '%". $slug ."%' OR `en_name` LIKE '%". $slug ."%' AND `parent_id` != 0");
$query = $this -> db -> get();
return $query -> result();
}