diff --git a/application/models/infoContents_model.php b/application/models/infoContents_model.php index 6e32a53a..c462aa07 100644 --- a/application/models/infoContents_model.php +++ b/application/models/infoContents_model.php @@ -11,7 +11,8 @@ class InfoContents_model extends CI_Model $this->HT = $this->load->database('INFORMATION', TRUE); } - public function add_use_ORM($table, $data) { + public function add_use_ORM($table, $data) + { if ($this->HT->insert($table, $data)) { return $this->HT->last_id($table); } else { @@ -19,89 +20,142 @@ class InfoContents_model extends CI_Model } } - public function update_use_ORM($table, $data, $where) { + public function update_use_ORM($table, $data, $where) + { $this->HT->update($table, $data, $where); } - function Add($ic_url, $ic_url_title, $ic_type, $ic_title, $ic_content, $ic_summary, $ic_seo_title, $ic_seo_description, $ic_seo_keywords, - $ic_show_bread_crumbs, $ic_status, $ic_template, $ic_photo, $ic_photo_width, $ic_photo_height, $ic_recommend_tours, $ic_recommend_packages, - $ic_ht_area_id, $ic_ht_area_type, $ic_ht_product_id, $ic_ht_product_type,$ic_author) - { - $ic_content=str_replace('http:'.$this->config->item('site_image_url'), $this->config->item('site_image_url'),$ic_content); - $ic_content=str_replace($this->config->item('media_image_url_remote2'), $this->config->item('site_image_url'),$ic_content); - $ic_content=str_replace($this->config->item('media_image_url_org'), $this->config->item('site_image_url'),$ic_content); - $ic_content=str_replace($this->config->item('media_image_url'), $this->config->item('site_image_url'),$ic_content); - $ic_content=str_replace($this->config->item('media_image_url2'), $this->config->item('site_image_url'),$ic_content); - $ic_content=str_replace($this->config->item('media_image_url_remote'), $this->config->item('site_image_url'),$ic_content); - $ic_content=str_replace($this->config->item('media_image_url3'), $this->config->item('site_image_url'),$ic_content); - $ic_content=str_replace($this->config->item('media_image_url_org2'), $this->config->item('site_image_url'),$ic_content); - $ic_content=str_replace('#textarea#', 'textarea',$ic_content); - $ic_content=str_replace('t_e_x_t_a_r_e_a', 'textarea',$ic_content); + function Add( + $ic_url, + $ic_url_title, + $ic_type, + $ic_title, + $ic_content, + $ic_summary, + $ic_seo_title, + $ic_seo_description, + $ic_seo_keywords, + $ic_show_bread_crumbs, + $ic_status, + $ic_template, + $ic_photo, + $ic_photo_width, + $ic_photo_height, + $ic_recommend_tours, + $ic_recommend_packages, + $ic_ht_area_id, + $ic_ht_area_type, + $ic_ht_product_id, + $ic_ht_product_type, + $ic_author + ) { + $ic_content = str_replace('http:' . $this->config->item('site_image_url'), $this->config->item('site_image_url'), $ic_content); + $ic_content = str_replace($this->config->item('media_image_url_remote2'), $this->config->item('site_image_url'), $ic_content); + $ic_content = str_replace($this->config->item('media_image_url_org'), $this->config->item('site_image_url'), $ic_content); + $ic_content = str_replace($this->config->item('media_image_url'), $this->config->item('site_image_url'), $ic_content); + $ic_content = str_replace($this->config->item('media_image_url2'), $this->config->item('site_image_url'), $ic_content); + $ic_content = str_replace($this->config->item('media_image_url_remote'), $this->config->item('site_image_url'), $ic_content); + $ic_content = str_replace($this->config->item('media_image_url3'), $this->config->item('site_image_url'), $ic_content); + $ic_content = str_replace($this->config->item('media_image_url_org2'), $this->config->item('site_image_url'), $ic_content); + $ic_content = str_replace('#textarea#', 'textarea', $ic_content); + $ic_content = str_replace('t_e_x_t_a_r_e_a', 'textarea', $ic_content); $sql = "INSERT INTO infoContents \n" - . " ( \n" - . " ic_url, ic_url_title, ic_type, ic_title, ic_content, ic_summary, ic_seo_title, \n" - . " ic_seo_description, ic_seo_keywords, ic_show_bread_crumbs, ic_status, \n" - . " ic_template, ic_photo,ic_photo_width,ic_photo_height, ic_sitecode, ic_recommend_tours, ic_recommend_packages, \n" - . " ic_ht_area_id, ic_ht_area_type,ic_ht_product_id,ic_ht_product_type,ic_author, ic_datetime \n" - . " ) \n" - . "VALUES \n" - . " ( N?,N?,?,N?,N?,N?,N?,N?,N?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,getdate() )"; - $query = $this->HT->query($sql, - array($ic_url, $ic_url_title, $ic_type, $ic_title, str_replace($this->config->item('media_image_url'), $this->config->item('site_image_url'), - $ic_content), - $ic_summary, $ic_seo_title, $ic_seo_description, $ic_seo_keywords, $ic_show_bread_crumbs, $ic_status, - $ic_template, $ic_photo, $ic_photo_width, $ic_photo_height, $this->config->item('site_code'), $ic_recommend_tours, $ic_recommend_packages, - $ic_ht_area_id, $ic_ht_area_type, $ic_ht_product_id, $ic_ht_product_type,$ic_author)); + . " ( \n" + . " ic_url, ic_url_title, ic_type, ic_title, ic_content, ic_summary, ic_seo_title, \n" + . " ic_seo_description, ic_seo_keywords, ic_show_bread_crumbs, ic_status, \n" + . " ic_template, ic_photo,ic_photo_width,ic_photo_height, ic_sitecode, ic_recommend_tours, ic_recommend_packages, \n" + . " ic_ht_area_id, ic_ht_area_type,ic_ht_product_id,ic_ht_product_type,ic_author, ic_datetime \n" + . " ) \n" + . "VALUES \n" + . " ( N?,N?,?,N?,N?,N?,N?,N?,N?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,getdate() )"; + $query = $this->HT->query( + $sql, + array( + $ic_url, $ic_url_title, $ic_type, $ic_title, str_replace( + $this->config->item('media_image_url'), + $this->config->item('site_image_url'), + $ic_content + ), + $ic_summary, $ic_seo_title, $ic_seo_description, $ic_seo_keywords, $ic_show_bread_crumbs, $ic_status, + $ic_template, $ic_photo, $ic_photo_width, $ic_photo_height, $this->config->item('site_code'), $ic_recommend_tours, $ic_recommend_packages, + $ic_ht_area_id, $ic_ht_area_type, $ic_ht_product_id, $ic_ht_product_type, $ic_author + ) + ); $this->insert_id = $this->HT->last_id('infoContents'); return $query; } - function Update($ic_id, $ic_url, $ic_url_title, $ic_type, $ic_title, $ic_content, $ic_summary, $ic_seo_title, $ic_seo_description, $ic_seo_keywords, - $ic_show_bread_crumbs, $ic_status, $ic_template, $ic_photo, $ic_photo_width, $ic_photo_height, $ic_recommend_tours, $ic_recommend_packages, - $ic_ht_area_id, $ic_ht_area_type, $ic_ht_product_id, $ic_ht_product_type,$ic_author) - { - $ic_content=str_replace('http:'.$this->config->item('site_image_url'), $this->config->item('site_image_url'),$ic_content); - $ic_content=str_replace($this->config->item('media_image_url'), $this->config->item('site_image_url'),$ic_content); - $ic_content=str_replace($this->config->item('media_image_url2'), $this->config->item('site_image_url'),$ic_content); - $ic_content=str_replace($this->config->item('media_image_url_org'), $this->config->item('site_image_url'),$ic_content); - $ic_content=str_replace($this->config->item('media_image_url_remote'), $this->config->item('site_image_url'),$ic_content); - $ic_content=str_replace($this->config->item('media_image_url_remote2'), $this->config->item('site_image_url'),$ic_content); - $ic_content=str_replace($this->config->item('media_image_url3'), $this->config->item('site_image_url'),$ic_content); - $ic_content=str_replace($this->config->item('media_image_url_org2'), $this->config->item('site_image_url'),$ic_content); - $ic_content=str_replace('#textarea#', 'textarea',$ic_content); - $ic_content=str_replace('t_e_x_t_a_r_e_a', 'textarea',$ic_content); + function Update( + $ic_id, + $ic_url, + $ic_url_title, + $ic_type, + $ic_title, + $ic_content, + $ic_summary, + $ic_seo_title, + $ic_seo_description, + $ic_seo_keywords, + $ic_show_bread_crumbs, + $ic_status, + $ic_template, + $ic_photo, + $ic_photo_width, + $ic_photo_height, + $ic_recommend_tours, + $ic_recommend_packages, + $ic_ht_area_id, + $ic_ht_area_type, + $ic_ht_product_id, + $ic_ht_product_type, + $ic_author + ) { + $ic_content = str_replace('http:' . $this->config->item('site_image_url'), $this->config->item('site_image_url'), $ic_content); + $ic_content = str_replace($this->config->item('media_image_url'), $this->config->item('site_image_url'), $ic_content); + $ic_content = str_replace($this->config->item('media_image_url2'), $this->config->item('site_image_url'), $ic_content); + $ic_content = str_replace($this->config->item('media_image_url_org'), $this->config->item('site_image_url'), $ic_content); + $ic_content = str_replace($this->config->item('media_image_url_remote'), $this->config->item('site_image_url'), $ic_content); + $ic_content = str_replace($this->config->item('media_image_url_remote2'), $this->config->item('site_image_url'), $ic_content); + $ic_content = str_replace($this->config->item('media_image_url3'), $this->config->item('site_image_url'), $ic_content); + $ic_content = str_replace($this->config->item('media_image_url_org2'), $this->config->item('site_image_url'), $ic_content); + $ic_content = str_replace('#textarea#', 'textarea', $ic_content); + $ic_content = str_replace('t_e_x_t_a_r_e_a', 'textarea', $ic_content); $sql = "UPDATE infoContents \n" - . "SET ic_url = N?, \n" - . " ic_url_title = N?, \n" - . " ic_type = ?, \n" - . " ic_title = N?, \n" - . " ic_content = N?, \n" - . " ic_summary = N?, \n" - . " ic_seo_title = N?, \n" - . " ic_seo_description = N?, \n" - . " ic_seo_keywords = N?, \n" - . " ic_show_bread_crumbs = ?, \n" - . " ic_status = ?, \n" - . " ic_template = ?, \n" - . " ic_photo = ?, \n" - . " ic_photo_width = ?, \n" - . " ic_photo_height = ?, \n" - . " ic_recommend_tours = ?, \n" - . " ic_recommend_packages = ?, \n" - . " ic_datetime = GETDATE() , \n" - . " ic_ht_area_id = ?, \n" - . " ic_ht_area_type = ?, \n" - . " ic_ht_product_id = ?, \n" - . " ic_ht_product_type = ?, \n" - . " ic_author = ? \n" - . "WHERE ic_id = ? \n" - . "AND ic_sitecode = ? "; - $query = $this->HT->query($sql, - array($ic_url, $ic_url_title, $ic_type, $ic_title, $ic_content, $ic_summary, - $ic_seo_title, $ic_seo_description, $ic_seo_keywords, $ic_show_bread_crumbs, $ic_status, $ic_template, $ic_photo, $ic_photo_width, $ic_photo_height, - $ic_recommend_tours, $ic_recommend_packages, $ic_ht_area_id, - $ic_ht_area_type, $ic_ht_product_id, $ic_ht_product_type,$ic_author, $ic_id,$this->config->item('site_code'))); + . "SET ic_url = N?, \n" + . " ic_url_title = N?, \n" + . " ic_type = ?, \n" + . " ic_title = N?, \n" + . " ic_content = N?, \n" + . " ic_summary = N?, \n" + . " ic_seo_title = N?, \n" + . " ic_seo_description = N?, \n" + . " ic_seo_keywords = N?, \n" + . " ic_show_bread_crumbs = ?, \n" + . " ic_status = ?, \n" + . " ic_template = ?, \n" + . " ic_photo = ?, \n" + . " ic_photo_width = ?, \n" + . " ic_photo_height = ?, \n" + . " ic_recommend_tours = ?, \n" + . " ic_recommend_packages = ?, \n" + . " ic_datetime = GETDATE() , \n" + . " ic_ht_area_id = ?, \n" + . " ic_ht_area_type = ?, \n" + . " ic_ht_product_id = ?, \n" + . " ic_ht_product_type = ?, \n" + . " ic_author = ? \n" + . "WHERE ic_id = ? \n" + . "AND ic_sitecode = ? "; + $query = $this->HT->query( + $sql, + array( + $ic_url, $ic_url_title, $ic_type, $ic_title, $ic_content, $ic_summary, + $ic_seo_title, $ic_seo_description, $ic_seo_keywords, $ic_show_bread_crumbs, $ic_status, $ic_template, $ic_photo, $ic_photo_width, $ic_photo_height, + $ic_recommend_tours, $ic_recommend_packages, $ic_ht_area_id, + $ic_ht_area_type, $ic_ht_product_id, $ic_ht_product_type, $ic_author, $ic_id, $this->config->item('site_code') + ) + ); return $query; } @@ -117,70 +171,60 @@ class InfoContents_model extends CI_Model function Delete($ic_id) { $sql = "DELETE \n" - . "FROM infoContents \n" - . "WHERE ic_id = ?"; + . "FROM infoContents \n" + . "WHERE ic_id = ?"; $query = $this->HT->query($sql, array($ic_id)); return $query; } - //递增浏览量 - function inc_views($sitecode,$page_url) - { - //查询信息需要过滤url上的域名 - if($page_url && $sitecode) - { - $page_url=substr($page_url,strpos($page_url,'/',8));//过滤掉url前面的http:// - $sql = "UPDATE infoContents \n" - . "SET ic_view = ISNULL(ic_view,0) + 1 \n" - . "WHERE ic_sitecode = ? AND ic_url = N?"; - return $this->HT->query($sql,array($sitecode,$page_url)); - } - } + //递增浏览量 + function inc_views($sitecode, $page_url) + { + //查询信息需要过滤url上的域名 + if ($page_url && $sitecode) { + $page_url = substr($page_url, strpos($page_url, '/', 8)); //过滤掉url前面的http:// + $sql = "UPDATE infoContents \n" + . "SET ic_view = ISNULL(ic_view,0) + 1 \n" + . "WHERE ic_sitecode = ? AND ic_url = N?"; + return $this->HT->query($sql, array($sitecode, $page_url)); + } + } public function get_ic_contents($ic_id) { - $sql="SELECT top 1 ic_id from infoContents where ic_id=?"; - $query=$this->HT->query($sql,array($ic_id)); - if ($query->result()) - { + $sql = "SELECT top 1 ic_id from infoContents where ic_id=?"; + $query = $this->HT->query($sql, array($ic_id)); + if ($query->result()) { $row = $query->row(); return $row; - } - else - { + } else { return FALSE; } } public function get_ic_contents2($ic_id) { - $sql="SELECT top 1 ic_id, ic_content, ic_title, ic_url, ic_photo, ic_sitecode, ic_seo_description from infoContents where ic_id=?"; - $query=$this->HT->query($sql,array($ic_id)); - if ($query->result()) - { + $sql = "SELECT top 1 ic_id, ic_content, ic_title, ic_url, ic_photo, ic_sitecode, ic_seo_description from infoContents where ic_id=?"; + $query = $this->INFORMATION->query($sql, array($ic_id)); + if ($query->result()) { $row = $query->row(); return $row; - } - else - { + } else { return FALSE; } } public function get_ic_contents_by_list($ic_id_list) { - $ic_id_list=trim($ic_id_list); - $ic_id_list.=0; - $sql="SELECT * from infoContents where ic_id in ($ic_id_list) order by charindex(','+ltrim(ic_id)+',', ',$ic_id_list,')"; - $query=$this->HT->query($sql); - if ($query->result()) - { + $ic_id_list = trim($ic_id_list); + $ic_id_list .= 0; + $sql = "SELECT * from infoContents where ic_id in ($ic_id_list) order by charindex(','+ltrim(ic_id)+',', ',$ic_id_list,')"; + $query = $this->HT->query($sql); + if ($query->result()) { $row = $query->result(); return $row; - } - else - { + } else { return FALSE; } } -} \ No newline at end of file +}