0
我有一串數據,我剝離了一些單詞,然後放入一個數組放入查詢。str_replace和like查詢
這個詞似乎很好剝奪,但類似的聲明,它仍然在拾起它們,並插入一個空白的搜索。這是在拖回所有的東西,這是不好的。
我不太確定爲什麼這樣做。我看起來不像是在單詞之間增加了一個額外的空格,而且我已經嘗試打印出數組,並且沒有看起來關閉,所以我不知所措。
這是我str_replace函數
$str = str_replace(array('and', 'this', 'that', 'or', 'boo', 'wound', 'but'), '', $userPost);
,我再在空間爆炸把它變成一個數組
$words = explode(' ', $str);
,然後在foreach我做我喜歡的語句
$this->db->or_where("`terms` LIKE '%$word%'");
和查詢是這樣出來的
SELECT * FROM (`filter_tbl`) WHERE `terms` LIKE '%real%' OR `terms` LIKE '%%' OR `terms` LIKE '%blank%' OR `terms` LIKE '%%' OR `terms` LIKE '%%' OR `terms` LIKE '%%' OR `terms` LIKE '%%' OR `terms` LIKE '%I%' OR `terms` LIKE '%love%' OR `terms` LIKE '%%' OR `terms` LIKE '%ty%' OR `terms` LIKE '%lets%' OR `terms` LIKE '%see%' OR `terms` LIKE '%if%' OR `terms` LIKE '%%' OR `terms` LIKE '%goes%' OR `terms` LIKE '%through%' OR `terms` LIKE '%please%' OR `terms` LIKE '%gg%' OR `terms` LIKE '%through%' OR `terms` LIKE '%%' OR `terms` LIKE '%%' OR `terms` LIKE '%%'
我知道這可能是簡單的東西我很想念,但我只是看不到它。幫助表示讚賞!
使用全文搜索替代 –
我正在使用全文,我只是想省略一些不必要的詞語 – zazvorniki
那麼你的查詢是錯誤的。 –