diff --git a/application/third_party/recommend/controllers/index.php b/application/third_party/recommend/controllers/index.php index bad6328d..3f492382 100644 --- a/application/third_party/recommend/controllers/index.php +++ b/application/third_party/recommend/controllers/index.php @@ -29,12 +29,14 @@ class Index extends CI_Controller public function search() { - $data = array(); - $data['groupList'] = $this->Information_model->group_list(); - $data['tipsList'] = $this->infoTips_model->get_list(); - $this->load->view('bootstrap3/header', $data); - $this->load->view('welcome'); - $this->load->view('bootstrap3/footer'); + + $keywords = $this->input->post('keywords'); + $data = array(); + $data['groupList'] = $this->Information_model->group_list(); + $data['tipsList'] = $this->infoTips_model->search($keywords); + $this->load->view('bootstrap3/header', $data); + $this->load->view('welcome'); + $this->load->view('bootstrap3/footer'); } //节点绑定信息推荐或者广告 diff --git a/application/third_party/recommend/models/infoTips_model.php b/application/third_party/recommend/models/infoTips_model.php index 18344f65..a73b92e2 100644 --- a/application/third_party/recommend/models/infoTips_model.php +++ b/application/third_party/recommend/models/infoTips_model.php @@ -56,6 +56,22 @@ class infoTips_model extends CI_Model } } + public function search($keywords) { + $keywordList = explode(" ", $keywords); + $whereCodition = ''; + foreach ($keywordList as $keyword) { + $whereCodition .= ' and '.$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(); + } public function add($table, $data) {