嗨由於某種原因,該工作我的搜索功能不起作用了我已經試過各種像/ or_like無濟於事的可能有人請點擊這裏伸出援助之手是我的控制器代碼:搜尋工作現在它不工作
function contractor(){
$keyword = $this->input->post('keyword');
$this->db->like($keyword);
$this->db->like('contractor_location',$keyword);
$this->db->like('contractor_email',$keyword);
$this->db->like('contractor_description',$keyword);
$this->db->like('contractor_number',$keyword);
$this->db->like('contractor_website',$keyword);
$this->db->join('category','contractors.contractorID=category_name.catagory_id','inner');
$this->db->group_by('contractor.contractorID');
$query = $this->db->get('contractors');
return $query->result();
}
UPDATE: 這是我收到遺憾的錯誤消息我忘了添加:
A Database Error Occurred
Error Number: 1064
You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near 'LIKE '%%' ESCAPE '!' AND `contractor_location` LIKE '%%' ESCAPE
'!' AND `contr' at line 4
SELECT * FROM `contractors` INNER JOIN `category` ON
`contractors`.`contractorID`=`category_name`.`catagory_id` WHERE LIKE
'%%' ESCAPE '!' AND `contractor_location` LIKE '%%' ESCAPE '!' AND
`contractor_email` LIKE '%%' ESCAPE '!' AND `contractor_description`
LIKE '%%' ESCAPE '!' AND `contractor_number` LIKE '%%' ESCAPE '!' AND
`contractor_website` LIKE '%%' ESCAPE '!' GROUP BY
`contractor`.`contractorID`
Filename: modules/search/models/Search_m.php
Line Number: 38
什麼'不工作'是什麼意思?沒有結果?錯誤?你有沒有做過任何研究(var_dumps,DB上的手動查詢等)? – Pietro
嗨對不起,我忘了添加錯誤,請參閱上面 – RiaanV