Multiple Like clause CodeIgniter

codeigniter like query with where clause
codeigniter join query with multiple where clause
codeigniter like wildcard
multiple if condition in codeigniter
like not working in codeigniter
how to use where and like together in codeigniter
multiple group by in codeigniter
and operator in codeigniter

I'm trying to use multiple 'Like' to look for matches in more than one column.

PHP & mysql:

$area = $this->session->userdata('area');
if($area == 'inbox'){

   $this->db->where('receiver',$user); 
   $this->db->where('receiver_deleted !=','yes');

   }elseif($area == 'sent'){
   $this->db->where('sender',$user); 
   $this->db->where('sender_deleted !=','yes');
}

$this->db->like('sender',$k);
$this->db->or_like('msg',$k); 


$this->db->from('messages');
$this->db->join('users','users.username = messages.sender','inner');

$this->db->order_by('read','no');
$sql = $this->db->get();

if($sql->num_rows > 0){

 return $sql->result();
}else{

 echo "failed!";
     }

I've also tried:

$this->db->like('sender',$k); 
$this->db->like('msg',$k); 

the first one nothing happens. The second one only one is executed, in this case the first like. I cannot get both to work at the same time.

Any help will be appreciated, Mike

or_like will produce an OR between the two likes. You can pass an array to like to put multiple with an AND between them.

Have you tried doing:

$this->db->like(array('sender' => $k, 'msg' => $k));

Multiple Like clause CodeIgniter, use this query hope it will help for you. $whereaccounts=array('role'=>0,'isActive' =>1);� Multiple Like Clauses Codeigniter. Ask Question Asked 3 years, 2 months ago. Active 2 years, 4 months ago. Viewed 3k times 1. I am trying to implement a search box

This will search multiple column with OR in between

$this->db->or_like(array('sender' => $k, 'msg' => $k));/* LIKE OR LIKE */

Multiple Like Clauses Codeigniter, You can simply repeat the like parameters on the active record. In your example you would do something like this: Codeigniter select query with multiple clause – Today we would love to share with how to use multiple clause with select query in codeigniter. Codeigniter provides many functions for select data for database. You will learn most important and basic functions for geting a data on database using multiple clause.

for this, you should use Grouping where clause.

$area = $this->session->userdata('area');
if($area == 'inbox'){

   $this->db->where('receiver',$user); 
   $this->db->where('receiver_deleted !=','yes');

   }elseif($area == 'sent'){
   $this->db->where('sender',$user); 
   $this->db->where('sender_deleted !=','yes');
}
$this->db->group_start();  //group start
$this->db->like('sender',$k);
$this->db->or_like('msg',$k); 
$this->db->group_end();  //group ed

Codeigniter database queries with multiple LIKE parameters, Multiple function calls can be made if you need several joins in one This method enables you to generate LIKE clauses, useful for doing� 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:

Use this:

$this->db->or_like('location',$this->input->post('searchtext'));
$this->db->or_like('title',$this->input->post('searchtext'));

and you will get exact you want.

Query Builder Class — CodeIgniter 4.0.4 documentation, Multiple function calls can be made if you need several joins in one query. This method enables you to generate LIKE clauses, useful for doing searches. Note. multiple where condition codeigniter using Associative array method. $multipleCIWhere = array ('name' => $name, 'title' => $title, 'isactive' => $isactive); $this->db->where ($multipleCIWhere); // Produces: WHERE name = 'Jaydeep' AND title = 'Gondaliya' AND isactive = 'active'.

You could do something like this:

$this->db->get_where('tablename',$whereclause);

I have the same problem and it worked.

Query Builder Class — CodeIgniter 3.1.11 documentation, Codeigniter provide set class function for each mysql function like where clause, join etc. So same for where clause, they provide "$this->db->� CodeIgniter gives you access to a Query Builder class. This pattern allows information to be retrieved, inserted, and updated in your database with minimal scripting. In some cases only one or two lines of code are necessary to perform a database action. CodeIgniter does not require that each

How to use multiple where condition in Codeigniter?, The or_where() function is similar as where() function, except that it joins multiple where() function calls with OR operator. Example:-. CodeIgniter gives you access to a Query Builder class. This pattern allows information to be retrieved, inserted, and updated in your database with minimal scripting. In some cases, only one or two lines of code are necessary to perform a database action. CodeIgniter does not require that each database table be its own class file.

CodeIgniter Select Query | W3Schools | Tutorialspoint, Grouping LIKE clause (putting parenthesis around) #1881. Closed If you are using a 2.x version of CodeIgniter, I don't think it exists yet. 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.

Grouping LIKE clause (putting parenthesis around) � Issue #1881 , Have you tried php - Multiple Like clause CodeIgniter - Stack Overflow. I'm trying to use multiple 'Like' to look for matches in more than one column. PHP &� Like clause is used in 'SELECT Query' to search for the matching pattern in columns. The operato This tutorial shows you how to write like query in codeigniter.

Comments
  • Show your raw sql query that you need to get it working using active record
  • It works but now it created another problem. The where clauses are being ignored. I edited the question to add the where clauses.
  • You can use having() condition like where().
  • This didn't answered the question