Hi Guys,
Here, i will show you how to write multiple condition in where clause using codeigniter 3 Query Builder class. Codeigniter provide set class function for each mysql function like where clause, join etc. So same for where clause, they provide "$this->db->where($array);", so we can use easily.
In this tutorial, you can see two way to add multiple where condition in your codeigniter application. So just let's see both example as below and do it same way:
Example 1:
$multipleWhere = ['name' => $name, 'email' => $email, 'status' => $status];
$this->db->where($multipleWhere);
$this->db->get("table_name");
Example 2:
$multipleWhere = ['name !=' => $name, 'id <' => $id, 'status >' => $status];
$this->db->where($multipleWhere);
$this->db->get("table_name");
As you can see both example.
I hope you find your best....
Do you like below Tutorials ?
- Laravel 5.6 - Collection could not be converted to int
- Laravel - How to generate secure https URL from route?
- Laravel - Vue JS File Upload Example
- How to get last 7 days data in Laravel?
- Laravel Validation required if other field empty example
- Laravel Eloquent - When Case Statement in Select Query Example
- Laravel 7.x and 6.x Passing Variable to Javascript Example
- How to pass PHP variables in JavaScript or jQuery?