How to use Multiple Where Condition in Codeigniter?

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);

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.

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.

Leave a Reply

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

Recent Posts

Related Post

Update Query in Codeigniter using Where Condition

Here, We displayed the best ways to update query in Codeigniter using where condition. Also, given an example of multiple where condition. Similarly, Codeigniter has to provide a simple query to replace data from the MySQL database using a clause. This is update query $this->db->replace(); Thus, I have to show an update function. This function […]

Read more

How to Delete Query with Where Condition in Codeigniter

I am showing the best method to learn of delete query with where condition in Codeigniter. As well as, explain Codeigniter delete query return value from the database. Also, given some example code of delete query. when using where condition in the below section. Delete Query with Where Condition in Codeigniter Here, We displaying a […]

Read more

How to use Join Query in Codeigniter

So, I am going to show you how to use a join query in Codeigniter. Also, retrieve the data as you want with example. Here, we have defined many ways to use join query with where condition. As well as, fetch data multiple methods like left join, right join, full join, and inner join in […]

Read more

x