diff --git a/application/controllers/information.php b/application/controllers/information.php index 3d94d096..35b89c22 100644 --- a/application/controllers/information.php +++ b/application/controllers/information.php @@ -256,8 +256,9 @@ class Information extends CI_Controller echo 'need 2 is_id v2'; return false; } + // 源节点 - $src = $this->InfoStructures_model->Detail($src_is_id); + $src = $this->InfoStructures_model->Detail_gm($src_is_id); $src_path = $this->Information_model->get_list_by_path($src->is_path, false, $src->is_sitecode); // 源子节点 foreach ($src_path as $n => $item) { @@ -265,6 +266,10 @@ class Information extends CI_Controller unset($src_path[$n]); } } + print_r($src); + print_r($src_path); + return false; + // 目标节点结构 $dest = $this->InfoStructures_model->Detail($dest_is_id); $dest_path = $this->Information_model->get_list_by_path($dest->is_path, false, $dest->is_sitecode); diff --git a/application/models/infoStructures_model.php b/application/models/infoStructures_model.php index fccabaf2..f88cfb5b 100644 --- a/application/models/infoStructures_model.php +++ b/application/models/infoStructures_model.php @@ -35,6 +35,28 @@ class InfoStructures_model extends CI_Model } } + function Detail_gm($is_id) + { + $sql = "SELECT TOP 1 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" + . "FROM information_gm.dbo.infoStructures is1 \n" + . "WHERE is1.is_id = ?"; + $query = $this->HT->query($sql, array($is_id)); + //print_r($this->HT->queries); + if ($query->result()) { + $row = $query->row(); + return $row; + } else { + return FALSE; + } + } + function Add($is_parent_id, $is_ic_id = -1, $is_sort = 999) { @@ -75,7 +97,7 @@ class InfoStructures_model extends CI_Model function Add_with_sitecode($is_parent_id, $is_ic_id = -1, $is_sort = 999, $site_code = '') { - if (empty($site_code)) { + if (empty ($site_code)) { $site_code = $this->config->item('site_code'); } if ($is_parent_id == 0) { diff --git a/application/models/information_model.php b/application/models/information_model.php index a80ffa61..8e37ebc8 100644 --- a/application/models/information_model.php +++ b/application/models/information_model.php @@ -155,6 +155,18 @@ class Information_model extends CI_Model return $this->GetList($filed, $site_code); } + //根据根节点路径获取子节点列表 + function get_list_by_path_gm($path, $level = false, $site_code = false, $filed = false) + { + $this->init(); + if ($level !== false) { + $this->level = " AND is1.is_level= '$level' "; + } + $this->path = " AND is1.is_path LIKE '$path%' "; + $this->orderBy = ' ORDER BY is1.is_level ASC, is1.is_sort ASC,is1.is_path ASC '; + return $this->GetList_gm($filed, $site_code); + } + /** * 获取当前页面的面包屑,不包括当前节点 */ @@ -303,7 +315,7 @@ class Information_model extends CI_Model function Detail($ic_url_is_id, $filed = '', $site_code = '') { - if (empty($ic_url_is_id)) { + if (empty ($ic_url_is_id)) { return false; } $this->init(); @@ -318,7 +330,7 @@ class Information_model extends CI_Model function detail_by_ic_id($ic_id) { - if (empty($ic_id)) { + if (empty ($ic_id)) { return false; } $this->init(); @@ -330,7 +342,7 @@ class Information_model extends CI_Model function GetList($filed = "", $site_code = "") { $this->topNum ? $sql = "SELECT TOP " . $this->topNum : $sql = "SELECT "; - if (empty($filed)) { + if (empty ($filed)) { $sql .= " is1.is_id, \n" . " is1.is_parent_id, \n" . " is1.is_path, \n" @@ -407,6 +419,86 @@ class Information_model extends CI_Model } } + function GetList_gm($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"; + } else { + $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 information_gm.dbo.infoStructures is1 \n" + . " INNER JOIN information_gm.dbo.infoContents ic ON ic.ic_id = is1.is_ic_id \n" + . " left JOIN information_gm.dbo.infoMetas map on ic.ic_id = map.im_ic_id AND map.im_key = 'meta_addon_picture' \n" + . " left JOIN information_gm.dbo.infoMetas mapm on ic.ic_id = mapm.im_ic_id AND mapm.im_key = 'meta_addon_picture_mobile' \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); + if ($this->topNum === 1) { + if ($query->num_rows() > 0) { + $row = $query->row(); + return $row; + } else { + return FALSE; + } + } else { + return $query->result(); + } + } + //根据区域信息获取根节点 function GetRoot($ic_ht_area_type, $ic_ht_area_id) { @@ -444,7 +536,7 @@ class Information_model extends CI_Model WHERE is1.is_id=?"; $query = $this->HT->query($sql, array($is_id)); $result = $query->result(); - if (!empty($result)) { + if (!empty ($result)) { return $result[0]->CII_PRI_SN; } else { return false;