Codeigniter parentheses in dynamic Active Record query

后端 未结 8 1581
死守一世寂寞
死守一世寂寞 2020-12-05 23:38

I\'m producing a query like the following using ActiveRecord

SELECT * FROM (`foods`) WHERE `type` = \'fruits\' AND 
       `tags` LIKE \'%green%\' OR `tags`          


        
8条回答
  •  既然无缘
    2020-12-05 23:56

    You can't add parentheses in ActiveRecord, but maybe WHERE IN is what you're looking for?

    $names = array('Frank', 'Todd', 'James');
    $this->db->where_in('username', $names);
    // Produces: WHERE username IN ('Frank', 'Todd', 'James')
    

提交回复
热议问题