есть вот такая форма
в нее вводятся поисковые слова через запятую и выбираются категории в которых нужно искать.
вот код...
после нажатия на поиск
загружается выбор результата
file profileController:
$v->autosearch = ProfileModel::Instance()->selectUserAutosearchKeywords($v->profile_data['u_id']);
$v->category_autosearch = unserialize($v->autosearch['tables']);
$v->tables = array('vacancies' => $profile['vacancies'], 'portfolio' => $profile['portfolio'], 'company' => $profile['company'], 'adverts' => $profile['adverts']);
if($v->category_autosearch) {
$v->autosearch_result = ProfileModel::Instance()->getAutosearchList($v->autosearch['keywords'], $v->category_autosearch);
foreach($v->autosearch_result as $k => $v) {
$v->autosearch_result[$k]['key_main_array'] = $profile[$k];
}
}
$v->profile_adverts = ProfileModel::Instance()->getListAdvertsForProfile($v->profile_data['u_id']);
file profileModel:
public function getAutosearchList ($keywords, $tables) {
$query = explode(',', $keywords);
$rez = array();
foreach ($tables as $t) {
if ($t == 'company') {
$select = 'u.id, u.onlineSatus, ud.user_img, ud.name, ud.lastname, ud.about';
$from = 'users as u, user_date as ud';
$where = 'MATCH(u.login, u.email, ud.name, ud.lastname, ud.mobile, ud.about, ud.company_name, ud.patent) AGAINST (:query IN BOOLEAN MODE) and u.validStatus = 1 and u.id = ud.user_id and ud.type_person = \'4\'';
foreach ($query as $k) {
$k = trim($k);
$param = array('query' => $k.'*');
$rez['company'][$k] = DBClass::Instance()->select($from, array($select), $where, $param, '', '', '', '', '', '2');
if(empty($rez['company'][$k])) $rez['company'][$k] = 'Null';
}
}
if ($t == 'portfolio') {
$select = 'p.id, p.portfolio_img, p.name, p.lastname, p.about, u.onlineSatus';
$from = 'portfolio as p, users as u';
$where = 'MATCH(p.name, p.lastname, p.about) AGAINST (:query IN BOOLEAN MODE) and search_status = 0 and u.validStatus = 1 and u.id = p.id_user';
foreach ($query as $k) {
$k = trim($k);
$param = array('query' => $k.'*');
$rez['portfolio'][$k] = DBClass::Instance()->select($from, array($select), $where, $param, '', '', '', '', '', '2');
}
}
if ($t == 'adverts') {
$select = 'a.id, a.seo, a.title, a.description';
$from = 'adverts as a';
$where = 'MATCH(a.title, a.description, a.keywords) AGAINST (:query IN BOOLEAN MODE) and validate = 1';
foreach ($query as $k) {
$k = trim($k);
$param = array('query' => $k.'*');
$rez['adverts'][$k] = DBClass::Instance()->select($from, array($select), $where, $param, '', '', '', '', '', '2');
}
}
if ($t == 'vacancies') {
$select = 'v.id, v.title, v.short_desc';
$from = 'vacancies as v';
$where = 'MATCH(v.title, v.short_desc, v.full_desc) AGAINST (:query IN BOOLEAN MODE) and valid_status = 1';
foreach ($query as $k) {
$k = trim($k);
$param = array('query' => $k.'*');
$rez['vacancies'][$k] = DBClass::Instance()->select($from, array($select), $where, $param, '', '', '', '', '', '2');
}
}
}
return $rez;
}
Warning: Attempt to modify property of non-object in Z:\home\fq.it\www\App\Controllers\ProfileController.php on line 42
ругается на:
$v->autosearch_result[$k]['key_main_array'] = $profile[$k]; //где $profile[$k]; - некая текстовая переменная