I have a model 'Mix' which has the fields (which I'd like to be searchable) 'name' 'description' and 'tag_words', as well as a boolean field 'published'. Users should be able to enter a multi-word search term and get results back for any of their words appearing in any of the searchable fields providing the 'published' field is set to 1
So far with the help of google and reading around on here I've got:
if ($this->request->is('post')) {
$conditions = array();
$search_terms = explode(' ', $this->request->data['Mix']['search']);
foreach($search_terms as $search_term){
$conditions[] = array('Mix.name Like' =>'%'.$search_term.'%');
$conditions[] = array('Mix.description Like' =>'%'.$search_term.'%');
$conditions[] = array('Mix.tag_words Like' =>'%'.$search_term.'%');
}
$searchResults = $this->paginate('Mix', array('conditions' => array('Mix.published'=>1, 'AND'=>array('OR' => $conditions))));
}
But since it returns nothing but loads of errors I can guess it's totally wrong. I've very confused, what is the correct syntax?