I\'m producing a query like the following using ActiveRecord
SELECT * FROM (`foods`) WHERE `type` = \'fruits\' AND
`tags` LIKE \'%green%\' OR `tags`
Just adding my successful solution:
$this->db->where("(table.field = $variable OR table.field IS NULL)");
One of best feature to save your query when you applying multiple where or_where clauses.
$this->db->group_start();
$this->db->where();
$this->db->or_where();
$this->db->group_end();
Happy Coding. :)