or_where condition in Codeigniter

CodeIgniter is a framework based on MVC principles. As a result, you would usually separate application logic, data abstraction and “output” into their respective areas for CodeIgniter use. In this case: controllers, models and views.

When someone trying to or conditions using the active record database library in Codeigniter. This function is identical to the one above, except that multiple instances are joined by OR.

Note: or_where() was formerly known as orwhere(), which has been removed.

Let’s create a or_where method in codeigniter

$this->db->where('username !=', $username);
$this->db->or_where('id >', $id);  // Produces: WHERE username != 'jhon' OR id > 20

Leave a Reply

Your email address will not be published. Required fields are marked *