add infofix

master
LMR 1 year ago
parent 91387297e0
commit 3645a67b45

@ -0,0 +1,37 @@
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class infofix extends CI_Controller
{
var $site_code = '';
function __construct()
{
parent::__construct();
$this->load->model('Information_model');
$this->site_code = $this->input->get('site_code') ? $this->input->get('site_code') : $this->config->item('site_code');
}
function list_info_by_keys($site = '', $keys = [])
{
$site = 'cht';
$keys = ['test', 'china-hi'];
// 容错
if (empty($site) || empty($keys)) {
echo json_encode(
array(
'data' => []
)
);
return false;
}
echo json_encode($this->Information_model->list_by_keywords($site, $keys));
}
}
//end of infofix

@ -783,4 +783,29 @@ class Information_model extends CI_Model
return $path_list; return $path_list;
} }
/**
* intl 根据keywords获取信息。
*/
function list_by_keywords($site, $keywords)
{
$this->init();
$keysql = '';
foreach ($keywords as $key) {
$keysql .= ' OR ic_content like \'%' . $key . '%\'';
}
$search = ' AND (1=0 ' . $keysql . ')';
$sql = "
SELECT TOP 10 ic_id, ic_url
FROM infoStructures is1
INNER JOIN infoContents ic ON ic.ic_id = is1.is_ic_id
AND ic.ic_sitecode = is1.is_sitecode
WHERE is1.is_sitecode = ?
" . $search . "
ORDER BY ic_datetime DESC
";
$query = $this->HT->query($sql, array($site));
// print_r($this->HT->queries);
return $query->result();
}
} }

Loading…
Cancel
Save