diff --git a/application/models/information_model.php b/application/models/information_model.php index bb6964bc..e323cd20 100644 --- a/application/models/information_model.php +++ b/application/models/information_model.php @@ -1,6 +1,7 @@ HT = $this->load->database('INFORMATION', TRUE); $this->HT229 = $this->load->database('HT', TRUE); } - function init() { + function init() + { $this->topNum = false; $this->orderBy = " ORDER BY ic_datetime DESC "; $this->search_title = false; @@ -39,13 +42,15 @@ class Information_model extends CI_Model { $this->ic_id = false; } - function get_last_edit_list($topNum = 24) { + function get_last_edit_list($topNum = 24) + { $this->init(); $this->topNum = $topNum; return $this->GetList(); } - function search($keyword) { + function search($keyword) + { $this->init(); $this->topNum = 24; if (is_numeric($keyword)) { @@ -57,7 +62,8 @@ class Information_model extends CI_Model { return $this->GetList(); } - function search_all_text($keyword,$topnum=24) { + function search_all_text($keyword, $topnum = 24) + { $this->init(); $this->topNum = $topnum; $sql_keyword = '%' . $this->HT->escape_like_str($keyword) . '%'; @@ -66,63 +72,68 @@ class Information_model extends CI_Model { } //根据关键词来搜索内容 - function search_by_words($url,array $words,$exclude_ids){ + function search_by_words($url, array $words, $exclude_ids) + { $this->init(); $this->topNum = 1; - $sql_keyword=' AND ( 1=1 '; + $sql_keyword = ' AND ( 1=1 '; foreach ($words as $item) { - $sql_keyword .=" AND ic_title like '%". $this->HT->escape_like_str(trim($item)) ."%' "; + $sql_keyword .= " AND ic_title like '%" . $this->HT->escape_like_str(trim($item)) . "%' "; } - $sql_keyword.=' ) '; - $this->search =" AND ic_status=1 AND ic_url LIKE '$url%' ". $sql_keyword.' AND is_id NOT IN('.implode(',',$exclude_ids).',0)'; + $sql_keyword .= ' ) '; + $this->search = " AND ic_status=1 AND ic_url LIKE '$url%' " . $sql_keyword . ' AND is_id NOT IN(' . implode(',', $exclude_ids) . ',0)'; $this->orderBy = " ORDER BY is1.is_level ASC, is1.is_sort ASC,ic_datetime DESC "; return $this->GetList('ic_id, is_id, ic_url,ic_url_title,ic_title,is_path,is_level,ic_status,ic.ic_photo'); } //在当前节点下搜索关键词 - function search_by_words_2($path,array $words,$exclude_ids){ + function search_by_words_2($path, array $words, $exclude_ids) + { $this->init(); $this->topNum = 1; - $sql_keyword=' AND ( 1=1 '; + $sql_keyword = ' AND ( 1=1 '; foreach ($words as $item) { - $sql_keyword .=" AND ic_title like '%". $this->HT->escape_like_str(trim($item)) ."%' "; + $sql_keyword .= " AND ic_title like '%" . $this->HT->escape_like_str(trim($item)) . "%' "; } - $sql_keyword.=' ) '; + $sql_keyword .= ' ) '; $this->path = " AND is1.is_path LIKE '$path%' "; - $this->search =' AND ic_status=1 AND is_id NOT IN('.implode(',',$exclude_ids).',0) '.$sql_keyword; + $this->search = ' AND ic_status=1 AND is_id NOT IN(' . implode(',', $exclude_ids) . ',0) ' . $sql_keyword; $this->orderBy = " ORDER BY is1.is_level ASC, is1.is_sort ASC,ic_datetime DESC "; return $this->GetList('ic_id, is_id, ic_url,ic_url_title,ic_title,is_path,is_level,ic_status,ic.ic_photo'); } //在同级别下,随机获取N条数据,并且排除某些id - function random($topnum,$is_path,array $exclude_ids){ + function random($topnum, $is_path, array $exclude_ids) + { $this->init(); $this->topNum = $topnum; $this->search = " AND is1.is_path LIKE '$is_path%' "; //$this->search = " AND is_parent_id =". $this->HT->escape($is_parent_id); - $exclude_ids_string=implode(',',$exclude_ids); + $exclude_ids_string = implode(',', $exclude_ids); $this->search .= " AND ic_status=1 AND is_id NOT in ($exclude_ids_string,0)"; $this->orderBy = " ORDER BY NewID() "; return $this->GetList('ic_id, is_id, ic_url,ic_url_title,ic_title,is_path,is_level,ic_status,ic.ic_photo'); } //在urls列表里面,随机获取N条数据,并且排除某些id - function random_range($topnum,array $url_array,array $exclude_ids){ + function random_range($topnum, array $url_array, array $exclude_ids) + { $this->init(); $this->topNum = $topnum; - $this->search =' AND ( 1=2 '; - foreach ($url_array as $item){ - $this->search .= ' OR ic_url= '.$this->HT->escape(trim($item)); + $this->search = ' AND ( 1=2 '; + foreach ($url_array as $item) { + $this->search .= ' OR ic_url= ' . $this->HT->escape(trim($item)); } - $this->search .=' )'; - $exclude_ids_string=implode(',',$exclude_ids); + $this->search .= ' )'; + $exclude_ids_string = implode(',', $exclude_ids); $this->search .= " AND ic_status=1 AND is_id NOT in ($exclude_ids_string,0)"; $this->orderBy = " ORDER BY NewID() "; return $this->GetList('ic_id, is_id, ic_url,ic_url_title,ic_title,is_path,is_level,ic_status,ic.ic_photo'); } //根据url搜索信息 - function search_url($url) { + function search_url($url) + { $this->init(); $this->topNum = 24; $this->search_url = ' AND ic_url= ' . $this->HT->escape($url); @@ -130,7 +141,8 @@ class Information_model extends CI_Model { } //根据根节点路径获取子节点列表 - function get_list_by_path($path, $level = false, $site_code = false,$filed=false) { + function get_list_by_path($path, $level = false, $site_code = false, $filed = false) + { $this->init(); if ($level !== false) { $this->level = " AND is1.is_level= '$level' "; @@ -143,7 +155,8 @@ class Information_model extends CI_Model { /** * 获取当前页面的面包屑,不包括当前节点 */ - function get_path_exclude_self($is_id, $path) { + function get_path_exclude_self($is_id, $path) + { $site_code = $this->config->item('site_code'); $path_query = $this->HT->query("select ic_id, is_id, ic_url,ic_url_title,ic_title,is_path,is_level,ic_status @@ -176,7 +189,7 @@ class Information_model extends CI_Model { ]; foreach ($path_result as $path_row) { - + $ic_url = $path_row->ic_url; $ic_url_title = $path_row->ic_url_title; @@ -202,7 +215,6 @@ class Information_model extends CI_Model { 'ic_url_title' => $path_row->ic_url_title ]; $path_list[] = $path_array; - } } @@ -210,7 +222,8 @@ class Information_model extends CI_Model { } //根据路径获取某一级别节点详细页 - function get_detail_by_path($path, $level) { + function get_detail_by_path($path, $level) + { $this->init(); $this->topNum = 1; $this->level = " AND is1.is_level= '$level' "; @@ -218,8 +231,9 @@ class Information_model extends CI_Model { $this->orderBy = ' ORDER BY is1.is_level ASC, is1.is_sort ASC,is1.is_path ASC '; return $this->GetList(); } - //根据节点ID列表获取信息 - function get_detail_by_ids($is_ids) { + //根据节点ID列表获取信息 + function get_detail_by_ids($is_ids) + { $this->init(); $this->is_id_array = " AND is1.is_id IN ($is_ids) "; $this->orderBy = ' ORDER BY is1.is_level ASC, is1.is_sort ASC,is1.is_path ASC '; @@ -227,7 +241,8 @@ class Information_model extends CI_Model { } //根据根节点ID获取子节点列表 - function get_list_by_id($is_parent_id, $level = false) { + function get_list_by_id($is_parent_id, $level = false) + { $this->init(); if ($level !== false) { $this->level = " AND is1.is_level= '$level' "; @@ -236,9 +251,10 @@ class Information_model extends CI_Model { $this->orderBy = ' ORDER BY is1.is_level ASC, is1.is_sort ASC,is1.is_path ASC '; return $this->GetList('is1.is_id, ic.ic_id, ic.ic_url, ic.ic_url_title, ic.ic_title, ic.ic_datetime, ic.ic_author'); } - - function Detail($ic_url_is_id,$filed='') { + + function Detail($ic_url_is_id, $filed = '') + { if (empty($ic_url_is_id)) { return false; } @@ -252,78 +268,80 @@ class Information_model extends CI_Model { return $this->GetList(); } - function detail_by_ic_id($ic_id) { + function detail_by_ic_id($ic_id) + { if (empty($ic_id)) { return false; } $this->init(); $this->topNum = 1; - $this->ic_url_is_id = " AND ic.ic_id = " . $this->HT->escape($ic_id); + $this->ic_url_is_id = " AND ic.ic_id = " . $this->HT->escape($ic_id); return $this->GetList(); } - function GetList($filed = "", $site_code = "") { + function GetList($filed = "", $site_code = "") + { $this->topNum ? $sql = "SELECT TOP " . $this->topNum : $sql = "SELECT "; if (empty($filed)) { $sql .= " is1.is_id, \n" - . " is1.is_parent_id, \n" - . " is1.is_path, \n" - . " is1.is_level, \n" - . " is1.is_sort, \n" - . " is1.is_sitecode, \n" - . " is1.is_datetime, \n" - . " is1.is_ic_id, \n" - . " ic.ic_id, \n" - . " ic.ic_url, \n" - . " ic.ic_url_title, \n" - . " ic.ic_type, \n" - . " ic.ic_title, \n" - . " ic.ic_content, \n" - . " ic.ic_summary, \n" - . " ic.ic_seo_title, \n" - . " ic.ic_seo_description, \n" - . " ic.ic_seo_keywords, \n" - . " ic.ic_show_bread_crumbs, \n" - . " ic.ic_status, \n" - . " ic.ic_template, \n" - . " ic.ic_photo, \n" - . " ic.ic_photo_width, \n" - . " ic.ic_photo_height, \n" - . " ic.ic_sitecode, \n" - . " ic.ic_recommend_tours, \n" - . " ic.ic_recommend_packages, \n" - . " ic.ic_datetime, \n" - . " ic.ic_ht_area_id, \n" - . " ic.ic_ht_area_type, \n" - . " ic.ic_ht_product_id, \n" - . " ic.ic_ht_product_type, \n" - . " ic.SRMS_SIC_Code, \n" - . " ic.SRMS_SIIT_Code, \n" - . " ic.ic_author \n"; + . " is1.is_parent_id, \n" + . " is1.is_path, \n" + . " is1.is_level, \n" + . " is1.is_sort, \n" + . " is1.is_sitecode, \n" + . " is1.is_datetime, \n" + . " is1.is_ic_id, \n" + . " ic.ic_id, \n" + . " ic.ic_url, \n" + . " ic.ic_url_title, \n" + . " ic.ic_type, \n" + . " ic.ic_title, \n" + . " ic.ic_content, \n" + . " ic.ic_summary, \n" + . " ic.ic_seo_title, \n" + . " ic.ic_seo_description, \n" + . " ic.ic_seo_keywords, \n" + . " ic.ic_show_bread_crumbs, \n" + . " ic.ic_status, \n" + . " ic.ic_template, \n" + . " ic.ic_photo, \n" + . " ic.ic_photo_width, \n" + . " ic.ic_photo_height, \n" + . " ic.ic_sitecode, \n" + . " ic.ic_recommend_tours, \n" + . " ic.ic_recommend_packages, \n" + . " ic.ic_datetime, \n" + . " ic.ic_ht_area_id, \n" + . " ic.ic_ht_area_type, \n" + . " ic.ic_ht_product_id, \n" + . " ic.ic_ht_product_type, \n" + . " ic.SRMS_SIC_Code, \n" + . " ic.SRMS_SIIT_Code, \n" + . " ic.ic_author \n"; } else { - $sql.=" $filed "; + $sql .= " $filed "; } //添加查询AMP发布状态 //$sql.=",isnull((select top 1 CONVERT(varchar, im_value) from infoMetas where im_ic_id=ic_id and im_key='AMP_STATUS'),0) as amp_status "; - $sql.=",0 as amp_status "; - $sql.="FROM infoStructures is1 \n" - . " INNER JOIN infoContents ic ON ic.ic_id = is1.is_ic_id \n" - . " AND ic.ic_sitecode = is1.is_sitecode \n" - . "WHERE is1.is_sitecode = ? "; - $this->search_title ? $sql.=$this->search_title : false; - $this->search_url ? $sql.=$this->search_url : false; - $this->search ? $sql.=$this->search : false; - $this->path ? $sql.=$this->path : false; - $this->level ? $sql.=$this->level : false; - $this->is_parent_id ? $sql.=$this->is_parent_id : false; - $this->is_id_array ? $sql.=$this->is_id_array : false; - $this->ic_url_is_id ? $sql.=$this->ic_url_is_id : false; - $this->ic_id ? $sql.=$this->ic_id : false; - $this->ic_type ? $sql.=$this->ic_type : false; - $this->ic_ht_area_type ? $sql.=$this->ic_ht_area_type : false; - $this->ic_ht_area_id ? $sql.=$this->ic_ht_area_id : false; - - $this->orderBy ? $sql.=$this->orderBy : false; + $sql .= ",0 as amp_status "; + $sql .= "FROM infoStructures is1 \n" + . " INNER JOIN infoContents ic ON ic.ic_id = is1.is_ic_id \n" + . " AND ic.ic_sitecode = is1.is_sitecode \n" + . "WHERE is1.is_sitecode = ? "; + $this->search_title ? $sql .= $this->search_title : false; + $this->search_url ? $sql .= $this->search_url : false; + $this->search ? $sql .= $this->search : false; + $this->path ? $sql .= $this->path : false; + $this->level ? $sql .= $this->level : false; + $this->is_parent_id ? $sql .= $this->is_parent_id : false; + $this->is_id_array ? $sql .= $this->is_id_array : false; + $this->ic_url_is_id ? $sql .= $this->ic_url_is_id : false; + $this->ic_id ? $sql .= $this->ic_id : false; + $this->ic_type ? $sql .= $this->ic_type : false; + $this->ic_ht_area_type ? $sql .= $this->ic_ht_area_type : false; + $this->ic_ht_area_id ? $sql .= $this->ic_ht_area_id : false; + + $this->orderBy ? $sql .= $this->orderBy : false; $query = $this->HT->query($sql, array($site_code ? $site_code : $this->config->item('site_code'))); //print_r($this->HT->queries); @@ -340,22 +358,23 @@ class Information_model extends CI_Model { } //根据区域信息获取根节点 - function GetRoot($ic_ht_area_type, $ic_ht_area_id) { + function GetRoot($ic_ht_area_type, $ic_ht_area_id) + { $sql = "SELECT TOP 1 is1.is_id, \n" - . " is1.is_parent_id, \n" - . " is1.is_path, \n" - . " is1.is_level, \n" - . " ic.ic_url_title \n" - . "FROM infoStructures is1 \n" - . " INNER JOIN infoContents ic ON ic.ic_id = is1.is_ic_id \n" - . " AND ic.ic_sitecode = is1.is_sitecode \n" - . "WHERE is1.is_sitecode = ? \n" - . " AND ic.ic_ht_area_type = ? \n" - . " AND ic.ic_ht_area_id = ? \n" - . "ORDER BY \n" - . " is1.is_level ASC, \n" - . " is1.is_sort ASC, \n" - . " is1.is_path ASC \n"; + . " is1.is_parent_id, \n" + . " is1.is_path, \n" + . " is1.is_level, \n" + . " ic.ic_url_title \n" + . "FROM infoStructures is1 \n" + . " INNER JOIN infoContents ic ON ic.ic_id = is1.is_ic_id \n" + . " AND ic.ic_sitecode = is1.is_sitecode \n" + . "WHERE is1.is_sitecode = ? \n" + . " AND ic.ic_ht_area_type = ? \n" + . " AND ic.ic_ht_area_id = ? \n" + . "ORDER BY \n" + . " is1.is_level ASC, \n" + . " is1.is_sort ASC, \n" + . " is1.is_path ASC \n"; $query = $this->HT->query($sql, array($this->config->item('site_code'), $ic_ht_area_type, $ic_ht_area_id)); if ($query->result()) { $row = $query->row(); @@ -366,7 +385,8 @@ class Information_model extends CI_Model { } //根据信息树id获取省份代号 - public function get_province_by_isid($is_id) { + public function get_province_by_isid($is_id) + { $sql = " SELECT top 1 CII_PRI_SN FROM infoStructures is1 INNER JOIN infoContents ic ON ic.ic_id = is1.is_ic_id @@ -382,34 +402,36 @@ class Information_model extends CI_Model { } //获取结构列表 - function StructureList($is_id) { + function StructureList($is_id) + { $sql = "SELECT is1.is_id AS id, \n" - . " is1.is_parent_id AS pId, \n" - . " ISNULL(ic.ic_url_title,'New Information') AS name , \n" - . " ISNULL(ic.ic_status,0) AS status, \n" - . " is1.is_path, \n" - . " is1.is_id \n" - . "FROM infoStructures is1 \n" - . " INNER JOIN infoContents ic ON ic.ic_id = is1.is_ic_id \n" - . "WHERE is1.is_id = ? \n" - . " OR ',' + is1.is_path LIKE '%,$is_id,%' \n" - . "ORDER BY \n" - . " is1.is_level ASC, \n" - . " is1.is_sort ASC, \n" - . " is1.is_path ASC \n"; + . " is1.is_parent_id AS pId, \n" + . " ISNULL(ic.ic_url_title,'New Information') AS name , \n" + . " ISNULL(ic.ic_status,0) AS status, \n" + . " is1.is_path, \n" + . " is1.is_id \n" + . "FROM infoStructures is1 \n" + . " INNER JOIN infoContents ic ON ic.ic_id = is1.is_ic_id \n" + . "WHERE is1.is_id = ? \n" + . " OR ',' + is1.is_path LIKE '%,$is_id,%' \n" + . "ORDER BY \n" + . " is1.is_level ASC, \n" + . " is1.is_sort ASC, \n" + . " is1.is_path ASC \n"; $query = $this->HT->query($sql, array($is_id)); //print_r($this->HT->queries); return $query->result(); } //检测链接是否重复 - function URLcheck($is_id, $ic_url) { + function URLcheck($is_id, $ic_url) + { $sql = "SELECT TOP 1 is1.is_id \n" - . "FROM infoStructures is1 \n" - . " INNER JOIN infoContents ic ON ic.ic_id = is1.is_ic_id \n" - . "WHERE is1.is_id <> ? \n " - . " AND ic.ic_url = ? \n" - . " AND ic.ic_sitecode=? "; + . "FROM infoStructures is1 \n" + . " INNER JOIN infoContents ic ON ic.ic_id = is1.is_ic_id \n" + . "WHERE is1.is_id <> ? \n " + . " AND ic.ic_url = ? \n" + . " AND ic.ic_sitecode=? "; $query = $this->HT->query($sql, array($is_id, $ic_url, $this->config->item('site_code'))); //print_r($this->HT->queries); if ($query->num_rows() > 0) { @@ -420,33 +442,35 @@ class Information_model extends CI_Model { } //获取没有绑定的景点列表 - function get_unlink_landscape_list($city_id) { + function get_unlink_landscape_list($city_id) + { $sql = "SELECT TOP 8 lsi.LSI_SN, \n" - . " lsi.LSI_City, \n" - . " lsi2.LSI2_Name, \n" - . " ci2.CII2_Name \n" - . "FROM LandScapeInfo lsi \n" - . " INNER JOIN LandScapeInfo2 lsi2 ON lsi2.LSI2_LSI_SN = lsi.LSI_SN \n" - . " AND lsi2.LSI2_LGC = ? \n" - . " INNER JOIN CItyInfo2 ci2 ON ci2.CII2_CII_SN = lsi.LSI_City \n" - . " AND ci2.CII2_LGC = ? \n" - . "WHERE lsi.LSI_Publish = 1 \n" - . " AND (lsi.LSI_ParentSN IS NULL OR lsi.LSI_ParentSN = 0) \n" - . " AND lsi.LSI_City = ? \n" - . " AND NOT EXISTS( \n" - . " SELECT TOP 1 1 \n" - . " FROM infoContents ic \n" - . " WHERE ic.ic_ht_product_type = 't' \n" - . " AND ic.ic_ht_product_id = lsi.LSI_SN \n" - . " ) \n" - . "ORDER BY \n" - . " lsi2.LSI2_SN DESC"; + . " lsi.LSI_City, \n" + . " lsi2.LSI2_Name, \n" + . " ci2.CII2_Name \n" + . "FROM tourmanager.dbo.LandScapeInfo lsi \n" + . " INNER JOIN tourmanager.dbo.LandScapeInfo2 lsi2 ON lsi2.LSI2_LSI_SN = lsi.LSI_SN \n" + . " AND lsi2.LSI2_LGC = ? \n" + . " INNER JOIN tourmanager.dbo.CItyInfo2 ci2 ON ci2.CII2_CII_SN = lsi.LSI_City \n" + . " AND ci2.CII2_LGC = ? \n" + . "WHERE lsi.LSI_Publish = 1 \n" + . " AND (lsi.LSI_ParentSN IS NULL OR lsi.LSI_ParentSN = 0) \n" + . " AND lsi.LSI_City = ? \n" + . " AND NOT EXISTS( \n" + . " SELECT TOP 1 1 \n" + . " FROM infoContents ic \n" + . " WHERE ic.ic_ht_product_type = 't' \n" + . " AND ic.ic_ht_product_id = lsi.LSI_SN \n" + . " ) \n" + . "ORDER BY \n" + . " lsi2.LSI2_SN DESC"; $query = $this->HT229->query($sql, array($this->config->item('site_lgc'), $this->config->item('site_lgc'), $city_id)); return $query->result(); } //获取根节点列表 - function root_type_list() { + function root_type_list() + { $this->init(); $this->orderBy = " ORDER BY ic.ic_url_title ASC "; $this->level = " AND is1.is_level=1 "; @@ -456,7 +480,8 @@ class Information_model extends CI_Model { } //获取某个信息类型详情 - function get_type_detail($type_name, $area_type, $area_id) { + function get_type_detail($type_name, $area_type, $area_id) + { $this->init(); $this->topNum = 1; $this->orderBy = " ORDER BY is1.is_level ASC "; @@ -467,7 +492,8 @@ class Information_model extends CI_Model { } //获取3年未更新的信息 - function get_oldest_info($yeardiff = 3, $has_no_pub = true, $empty_info = true) { + function get_oldest_info($yeardiff = 3, $has_no_pub = true, $empty_info = true) + { $has_no_pub ? $sql_no_pub = '' : $sql_no_pub = "AND ic_status = 1"; $empty_info ? $sql_empty_info = '' : $sql_empty_info = "AND datalength(ic_content) > 0"; //sql @@ -487,8 +513,8 @@ class Information_model extends CI_Model { LEFT JOIN infoStructures ON ic_id = is_ic_id WHERE YEAR(GETDATE()) - YEAR(ic_datetime) >= ? AND ic_sitecode = ? - ".$sql_no_pub." - ".$sql_empty_info." + " . $sql_no_pub . " + " . $sql_empty_info . " AND ic_url <> '' ORDER BY ic_datetime desc"; $query = $this->HT->query($sql, array($yeardiff, $this->config->item('site_code'))); @@ -497,9 +523,9 @@ class Information_model extends CI_Model { //ct - function ct_get_by_url($ic_url,$webcode) + function ct_get_by_url($ic_url, $webcode) { - $this->ic_url_is_id=" AND ic.ic_url = N".$this->HT->escape($ic_url); + $this->ic_url_is_id = " AND ic.ic_url = N" . $this->HT->escape($ic_url); $sql = "SELECT is1.is_id, \n" . " is1.is_parent_id, \n" . " is1.is_path, \n" @@ -523,7 +549,7 @@ class Information_model extends CI_Model { . " ic.ic_template, \n" . " ic.ic_photo, \n" . " ic.ic_photo_width, \n" - . " ic.ic_photo_height, \n" + . " ic.ic_photo_height, \n" . " ic.ic_sitecode, \n" . " ic.ic_recommend_tours, \n" . " ic.ic_recommend_packages, \n" @@ -532,7 +558,7 @@ class Information_model extends CI_Model { . " ic.ic_ht_area_type, \n" . " ic.ic_ht_product_id, \n" . " ic.ic_ht_product_type, \n" - . " ic.ic_author \n" + . " ic.ic_author \n" . " FROM infoStructures is1 \n" . " INNER JOIN infoContents ic ON ic.ic_id = is1.is_ic_id \n" . " AND ic.ic_sitecode = is1.is_sitecode \n" @@ -541,21 +567,23 @@ class Information_model extends CI_Model { $query = $this->HT->query($sql, $webcode); // print_r($this->HT->queries); - return $query->row(); + return $query->row(); } - - //获取分组列表 - function group_list(){ - $this->init(); - $this->search =' AND is_level<=1 '; - $this->orderBy = ' ORDER BY is1.is_level ASC, is1.is_sort ASC,ic.ic_title ASC,is1.is_path ASC '; - return $this->GetList(); - } - - /** + + //获取分组列表 + function group_list() + { + $this->init(); + $this->search = ' AND is_level<=1 '; + $this->orderBy = ' ORDER BY is1.is_level ASC, is1.is_sort ASC,ic.ic_title ASC,is1.is_path ASC '; + return $this->GetList(); + } + + /** * CT 获取当前页面的面包屑,不包括当前节点,去除链接为空及不发布的节点 */ - function get_path_exclude_ct($is_id, $path) { + function get_path_exclude_ct($is_id, $path) + { $site_code = $this->config->item('site_code'); $path_query = $this->HT->query("select ic_id, is_id, ic_url,ic_url_title,ic_title,is_path,is_level,ic_status @@ -588,7 +616,7 @@ class Information_model extends CI_Model { ]; foreach ($path_result as $path_row) { - + if (array_key_exists($path_row->is_id, $group_map)) { $top_group = $group_map[$path_row->is_id]; $path_array = [ @@ -599,8 +627,7 @@ class Information_model extends CI_Model { 'ic_url_title' => $top_group['ic_url_title'] ]; $path_list[] = $path_array; - } - else if ($path_row->ic_status === 1) { + } else if ($path_row->ic_status === 1) { $path_array = [ 'ic_id' => $path_row->ic_id, 'is_id' => $path_row->is_id, @@ -609,11 +636,9 @@ class Information_model extends CI_Model { 'ic_url_title' => $path_row->ic_url_title ]; $path_list[] = $path_array; - } } return $path_list; } - } diff --git a/application/models/landscape_model.php b/application/models/landscape_model.php index 912ca745..d30da8ea 100644 --- a/application/models/landscape_model.php +++ b/application/models/landscape_model.php @@ -12,18 +12,18 @@ class Landscape_model extends CI_Model function search_list($keyword) { $sql = "SELECT TOP 8 lsi.LSI_SN, \n" - . " lsi.LSI_ID, \n" - . " lsi.LSI_City, \n" - . " lsi2.LSI2_Name, \n" - . " ci2.CII2_Name \n" - . "FROM LandScapeInfo lsi \n" - . " INNER JOIN LandScapeInfo2 lsi2 ON lsi2.LSI2_LSI_SN = lsi.LSI_SN \n" - . " AND lsi2.LSI2_LGC = ? \n" - . " INNER JOIN CItyInfo2 ci2 ON ci2.CII2_CII_SN = lsi.LSI_City \n" - . " AND ci2.CII2_LGC = ? \n" - . "WHERE lsi.LSI_Publish = 1 \n" - . " AND (lsi.LSI_ParentSN IS NULL OR lsi.LSI_ParentSN = 0) \n" - . " AND lsi2.LSI2_Name LIKE N? "; + . " lsi.LSI_ID, \n" + . " lsi.LSI_City, \n" + . " lsi2.LSI2_Name, \n" + . " ci2.CII2_Name \n" + . "FROM tourmanager.dbo.LandScapeInfo lsi \n" + . " INNER JOIN tourmanager.dbo.LandScapeInfo2 lsi2 ON lsi2.LSI2_LSI_SN = lsi.LSI_SN \n" + . " AND lsi2.LSI2_LGC = ? \n" + . " INNER JOIN tourmanager.dbo.CItyInfo2 ci2 ON ci2.CII2_CII_SN = lsi.LSI_City \n" + . " AND ci2.CII2_LGC = ? \n" + . "WHERE lsi.LSI_Publish = 1 \n" + . " AND (lsi.LSI_ParentSN IS NULL OR lsi.LSI_ParentSN = 0) \n" + . " AND lsi2.LSI2_Name LIKE N? "; $query = $this->HT->query($sql, array($this->config->item('site_lgc'), $this->config->item('site_lgc'), '%' . urldecode($keyword) . '%')); //print_r($this->HT->queries); return $query->result(); @@ -32,23 +32,20 @@ class Landscape_model extends CI_Model function get_landscape_title($lsi_sn) { $sql = "SELECT TOP 1 lsi2.LSI2_Name \n" - . "FROM LandScapeInfo lsi \n" - . " INNER JOIN LandScapeInfo2 lsi2 ON lsi2.LSI2_LSI_SN = lsi.LSI_SN \n" - . " AND lsi2.LSI2_LGC = ? \n" - . " INNER JOIN CItyInfo2 ci2 ON ci2.CII2_CII_SN = lsi.LSI_City \n" - . " AND ci2.CII2_LGC = ? \n" - . "WHERE lsi.LSI_Publish = 1 \n" - . " AND (lsi.LSI_ParentSN IS NULL OR lsi.LSI_ParentSN = 0) \n" - . " AND lsi.LSI_SN = ?"; - $query = $this->HT->query($sql, array($this->config->item('site_lgc'), $this->config->item('site_lgc'),$lsi_sn)); + . "FROM LandScapeInfo lsi \n" + . " INNER JOIN LandScapeInfo2 lsi2 ON lsi2.LSI2_LSI_SN = lsi.LSI_SN \n" + . " AND lsi2.LSI2_LGC = ? \n" + . " INNER JOIN CItyInfo2 ci2 ON ci2.CII2_CII_SN = lsi.LSI_City \n" + . " AND ci2.CII2_LGC = ? \n" + . "WHERE lsi.LSI_Publish = 1 \n" + . " AND (lsi.LSI_ParentSN IS NULL OR lsi.LSI_ParentSN = 0) \n" + . " AND lsi.LSI_SN = ?"; + $query = $this->HT->query($sql, array($this->config->item('site_lgc'), $this->config->item('site_lgc'), $lsi_sn)); //print_r($this->HT->queries); - if ($query->result()) - { + if ($query->result()) { $row = $query->row(); return $row->LSI2_Name; - } - else - { + } else { return FALSE; } } @@ -58,31 +55,26 @@ class Landscape_model extends CI_Model function get_detail($lsi_sn) { $sql = "SELECT TOP 1 lsi.LSI_SN, \n" - . " lsi.LSI_ID, \n" - . " lsi.LSI_City, \n" - . " lsi2.LSI2_Name, \n" - . " lsi2.LSI2_Intro, \n" - . " lsi2.LSI2_ShortIntro, \n" - . " ci2.CII2_Name \n" - . "FROM LandScapeInfo lsi \n" - . " INNER JOIN LandScapeInfo2 lsi2 ON lsi2.LSI2_LSI_SN = lsi.LSI_SN \n" - . " AND lsi2.LSI2_LGC = ? \n" - . " INNER JOIN CItyInfo2 ci2 ON ci2.CII2_CII_SN = lsi.LSI_City \n" - . " AND ci2.CII2_LGC = ? \n" - . "WHERE lsi.LSI_Publish = 1 \n" - . " AND (lsi.LSI_ParentSN IS NULL OR lsi.LSI_ParentSN = 0) \n" - . " AND lsi.LSI_SN = ?"; + . " lsi.LSI_ID, \n" + . " lsi.LSI_City, \n" + . " lsi2.LSI2_Name, \n" + . " lsi2.LSI2_Intro, \n" + . " lsi2.LSI2_ShortIntro, \n" + . " ci2.CII2_Name \n" + . "FROM LandScapeInfo lsi \n" + . " INNER JOIN LandScapeInfo2 lsi2 ON lsi2.LSI2_LSI_SN = lsi.LSI_SN \n" + . " AND lsi2.LSI2_LGC = ? \n" + . " INNER JOIN CItyInfo2 ci2 ON ci2.CII2_CII_SN = lsi.LSI_City \n" + . " AND ci2.CII2_LGC = ? \n" + . "WHERE lsi.LSI_Publish = 1 \n" + . " AND (lsi.LSI_ParentSN IS NULL OR lsi.LSI_ParentSN = 0) \n" + . " AND lsi.LSI_SN = ?"; $query = $this->HT->query($sql, array($this->config->item('site_lgc'), $this->config->item('site_lgc'), $lsi_sn)); - if ($query->num_rows() > 0) - { + if ($query->num_rows() > 0) { $row = $query->row(); return $row; - } - else - { + } else { return FALSE; - } + } } - - -} \ No newline at end of file +}