diff --git a/application/third_party/recommend/models/infoTips_model.php b/application/third_party/recommend/models/infoTips_model.php index a73b92e2..345bd7f1 100644 --- a/application/third_party/recommend/models/infoTips_model.php +++ b/application/third_party/recommend/models/infoTips_model.php @@ -58,19 +58,24 @@ class infoTips_model extends CI_Model public function search($keywords) { $keywordList = explode(" ", $keywords); - $whereCodition = ''; - foreach ($keywordList as $keyword) { - $whereCodition .= ' and '.$keyword; + $whereCodition = ' and ('; + foreach ($keywordList as $index => $keyword) { + if ($index > 0) { + $whereCodition .= " or "; + } + $whereCodition .= "it.it_title like '%" . $keyword . "%'"; + } + foreach ($keywordList as $index => $keyword) { + $whereCodition .= " or it.it_content like '%" . $keyword . "%'"; } $searchText = "select it.it_id ,it.it_title,it.it_expires,it.it_code,it.it_content,it.it_sitecode,it.it_datetime from infoTips it where it.it_sitecode=?" - . $whereCodition - . "order by it_expires ASC"; - // $query = $this->HT->query($searchText, array($this->config->item('site_code'))); - echo $this->HT->query_string($searchText, array($this->config->item('site_code'))); - // return $query->result(); + . $whereCodition . ") " + . " order by it_expires ASC"; + $query = $this->HT->query($searchText, array($this->config->item('site_code'))); + return $query->result(); } public function add($table, $data)