Codeigniter LIKE with wildcard(%)
activerecord, codeigniter, mysql, php, sql
Solution
`$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');
See the CI documentation for reference: CI 2, CI 3, CI 4
Problem
I have simple database query in codeigniter, however I cannot get search to work with wildcard. This is my code: ``` $this->db->like('film.title',"%$query%"); $this->db->escape_like_str($query); $res = $this->db->get('film'); ``` If I remove wildcard(%) then search works fine. Also $query is just string with user input. Any help is appreciated.