You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
information-system/author/models/information_model.php

128 lines
4.6 KiB
PHP

<?php
class Information_model extends CI_Model {
var $topNum = false;
var $orderBy = false;
var $search_title = false;
var $search_url = false;
var $path = false;
var $level = false;
var $is_parent_id = false;
var $is_id_array = false;
var $ic_url_is_id = false;
var $ic_ht_area_type = false;
var $ic_ht_area_id = false;
var $ic_type = false;
var $ic_id = false;
function __construct() {
parent::__construct();
$this->HT = $this->load->database('HT', TRUE);
}
function init() {
$this->topNum = false;
$this->orderBy = " ORDER BY ic_datetime DESC ";
$this->search_title = false;
$this->search_url = false;
$this->path = false;
$this->level = false;
$this->is_parent_id = false;
$this->is_id_array = false;
$this->ic_url_is_id = false;
$this->ic_ht_area_type = false;
$this->ic_ht_area_id = false;
$this->ic_type = false;
$this->ic_id = false;
}
function search($keyword) {
$this->init();
$this->topNum = 24;
if (is_numeric($keyword)) {
$this->search_title = "AND ic_id=" . $this->HT->escape($keyword);
} else {
$sql_keyword = '%' . $this->HT->escape_like_str($keyword) . '%';
$this->search_title = "AND (ic_url_title like N'$sql_keyword' OR ic_title like N'$sql_keyword' )";
}
return $this->GetList();
}
//根据url搜索信息
function search_url($url) {
$this->init();
$this->topNum = 24;
$this->search_url = ' AND ic_url= ' . $this->HT->escape($url);
return $this->GetList();
}
function GetList() {
$this->topNum ? $sql = "SELECT TOP " . $this->topNum : $sql = "SELECT ";
$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.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"
. "WHERE is1.is_sitecode = ? ";
$this->search_title ? $sql.=$this->search_title : false;
$this->search_url ? $sql.=$this->search_url : 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('cht'));
//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();
}
}
}