From eecb2a00e4d5dc3372b3d2e42d5551c76f6b26e7 Mon Sep 17 00:00:00 2001 From: Jimmy Liow Date: Tue, 7 Nov 2023 14:20:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=A1=E6=81=AF=E5=B9=B3=E5=8F=B0=E7=9A=84?= =?UTF-8?q?=E5=B9=BF=E5=91=8A=E7=AE=A1=E7=90=86=E6=96=B0=E5=A2=9E=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../recommend/models/infoTips_model.php | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) 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)