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

  1. if using mysql version 5.5 or lower, make sure tables involved have engine myisam.
  2. make sure column has fulltext index.
  3. where() takes 3 arguments, example:

    $this->db->where('match (field) against ("value")', null, false); $this->db->get('table');   
  4. more 1 columns in match() triggers error number: 1191, separate them:

    ->where('match (content.title) against ("'. $searchterm .'")') ->where('match (content.body) against ("'. $searchterm .'")') 

Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -