Here, we displaying the best method to use multiple where condition in Codeigniter.
Also, displaying another method get_where() and multiple where clause in Codeigniter.
As well as, given an example fetch data from the database using multiple where condition.
likewise, insert, update, and delete. It means all Codeigniter queries with used multiple where clause.
public function getdata(){
$data = array('name' => 'Rockky');
$multiClause = array('id' => $ids, 'name' => $name, 'status' => 1 );
$this->db->where($multiClause);
$query = $this->db->get('table-name', $data);
return $query->result();
}
Again, This example of the store all where conditions value an array and added variable in the below section.
After that, pass variable in where function in Codeigniter.
$multiClause = array('id' => $ids, 'name' => $name, 'status' => 1 );
$this->db->where($multiClause);
Table of Contents
Use Multiple Where Condition in Codeigniter
Here, we are showing the best example to understand for multiple Where condition with insert query.
Insert Query with multiple where condition in Codeigniter
$data = array('name' => 'Rockky');
$multiClause = array('id' => $ids, 'name' => $name, 'status' => 1 );
$this->db->where($multiClause);
$query = $this->db->insert('user', $data);
So, in this above section provide insert query with the using multiple where condition in Codeigniter.
As well as, know about $this->db->insert(‘user’, $data) this is insert query. Also, Insert query to access a variable to implement and then return value.
Update query with multiple where Clause in CI
$data = array('name' => 'Rockky');
$multiClause = array('id' => $ids, 'name' => $name, 'status' => 1 );
$this->db->where($multiClause);
$this->db->update('user', $data);
Similarly, you can use multiple where clause condition here. Now, only different queries like updates.
As an example, above section we used update query $this->db->update()
Delete Query with multiple where Clause in CI
This paragraph, showing another example to use multiple where conditions for delete data from the database.
$multiClause = array('id' => $ids, 'status' => 1 );
$this->db->delete('table name');
Thus, there is a code that denotes delete data. using multiple where clause in CI.
As well as, array check data and apply the condition. So, when data delete with condition from the database table.
Here you can learn more relative methods using Codeigniter.
- Update Query in Codeigniter using Where Condition
- How to Delete Query with Where Condition in Codeigniter
- How to use Join Query in Codeigniter
- CodeIgniter Tutorial
Conclusion
In this article, explain the best ways to use multiple where conditions in Codeigniter.
So, if you have any issue regarding ask us in the comment section.