full text search in codeigniter -
i have query search keywords using like
but want search full text changed full text search query, doesn't work.
so please me find reason.
the old query that's working fine:
$data = $this->db ->select('content.title,content.id,content.category,content.body,path') ->from('content') ->join('categories','content.category = categories.id') ->like('content.title', $searchterm) ->like('content.body', $searchterm) ->order_by("content.id","desc") ->get();
and new query full text search:
$data = $this->db ->select('content.title,content.id,content.category,content.body,path') ->from('content') ->join('categories','content.category = categories.id') ->where('match (content.body, content.title) against ("'. $searchterm .'")') ->order_by("content.id","desc") ->get();
- if using mysql version 5.5 or lower, make sure tables involved have engine myisam.
- make sure column has fulltext index.
where() takes 3 arguments, example:
$this->db->where('match (field) against ("value")', null, false); $this->db->get('table');
more 1 columns in
match()
triggers error number: 1191, separate them:->where('match (content.title) against ("'. $searchterm .'")') ->where('match (content.body) against ("'. $searchterm .'")')
Comments
Post a Comment