Codeigniter LIKE with wildcard(%)
$this->db->like()
automatically adds the %s and escapes the string. So all you need is
$this->db->like('title', $query);$res = $this->db->get('film');
$this->db->like('title', 'match', 'before'); // Produces: WHERE title LIKE '%match' $this->db->like('title', 'match', 'after'); // Produces: WHERE title LIKE 'match%' $this->db->like('title', 'match', 'both'); // Produces: WHERE title LIKE '%match%'
For Full like you can user :
$this->db->like('title',$query);
For %$query you can use
$this->db->like('title', $query, 'before');
and for $query% you can use
$this->db->like('title', $query, 'after');