-2
我有一個搜索輸入來搜索標題字段,我想通過title
和description
字段搜索具有相同輸入的字段,這是可行的嗎?CakePHP在兩個字段中搜索
這是我的搜索funtion:
$query = $this->request->query['search'];
$category_id = $this->request->query['category_id'];
$multimedia_type_id = $this->request->query['multimedia_type_id'];
$conditions = array(
'conditions' => array(
'and' => array()));
if ($query) $conditions['conditions']['and']['Multimedia.title LIKE' ] = "%$query%";
if ($category_id) $conditions['conditions']['and']['Multimedia.category_id'] = $category_id ;
if ($multimedia_type_id) $conditions['conditions']['and']['Multimedia.multimedia_type_id'] = $multimedia_type_id ;
我想在同一時間
我必須把這個: 'Multimedia.title', 'Multimedia.description' 數組裏面()? – GusDev
是的......爲什麼不呢? – gmponos
它的工作原理,謝謝 – GusDev