|
|
|
<?php
|
|
|
|
|
|
|
|
class InfoMetas_model extends CI_Model {
|
|
|
|
|
|
|
|
function __construct() {
|
|
|
|
parent::__construct();
|
|
|
|
$this->HT = $this->load->database('HT', TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
function add($im_ic_id, $im_key, $im_value) {
|
|
|
|
$sql = "INSERT INTO infoMetas \n"
|
|
|
|
. " ( \n"
|
|
|
|
. " im_ic_id, im_key, im_value \n"
|
|
|
|
. " ) \n"
|
|
|
|
. "VALUES \n"
|
|
|
|
. " ( \n"
|
|
|
|
. " ?, ?, N? \n"
|
|
|
|
. " )";
|
|
|
|
return $this->HT->query($sql, array($im_ic_id, $im_key, $im_value));
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_list($im_ic_id, $im_key) {
|
|
|
|
$sql = "
|
|
|
|
SELECT im.im_id
|
|
|
|
,im.im_ic_id
|
|
|
|
,im.im_key
|
|
|
|
,im.im_value
|
|
|
|
FROM infoMetas im
|
|
|
|
WHERE im.im_ic_id = ?
|
|
|
|
AND im.im_key = ?
|
|
|
|
ORDER BY im.im_id ASC
|
|
|
|
";
|
|
|
|
$query = $this->HT->query($sql, array($im_ic_id, $im_key));
|
|
|
|
return $query->result();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function list_amp($site_code) {
|
|
|
|
$sql = "
|
|
|
|
SELECT im.im_id
|
|
|
|
,im.im_ic_id
|
|
|
|
,im.im_key
|
|
|
|
,im.im_value as amp_json
|
|
|
|
,im2.im_value as amp_staus
|
|
|
|
,im3.im_value as amp_schema
|
|
|
|
FROM infoMetas im
|
|
|
|
inner join infoContents c
|
|
|
|
on c.ic_id = im.im_ic_id
|
|
|
|
left join infoMetas im2
|
|
|
|
on im2.im_ic_id = im.im_ic_id and im2.im_key = 'AMP_STATUS'
|
|
|
|
left join infoMetas im3
|
|
|
|
on im3.im_ic_id = im.im_ic_id and im2.im_key = 'AMP_SCHEMA'
|
|
|
|
WHERE im.im_key = 'AMP_JSON'
|
|
|
|
and c.ic_sitecode = ?
|
|
|
|
and CONVERT(varchar, im2.im_value) = '1'
|
|
|
|
";
|
|
|
|
$query = $this->HT->query($sql, array($site_code));
|
|
|
|
return $query->result();
|
|
|
|
}
|
|
|
|
|
|
|
|
function get($im_ic_id, $im_key) {
|
|
|
|
$sql = "SELECT im.im_value \n"
|
|
|
|
. "FROM infoMetas im \n"
|
|
|
|
. "WHERE im.im_ic_id = ? \n"
|
|
|
|
. " AND im.im_key = ?";
|
|
|
|
$query = $this->HT->query($sql, array($im_ic_id, $im_key));
|
|
|
|
if ($query->num_rows() > 0) {
|
|
|
|
return $query->row()->im_value;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function detail($im_ic_id, $im_key) {
|
|
|
|
$sql = "SELECT im.im_value \n"
|
|
|
|
. "FROM infoMetas im \n"
|
|
|
|
. "WHERE im.im_ic_id = ? \n"
|
|
|
|
. " AND im.im_key = ? ORDER BY im.im_id asc";
|
|
|
|
$query = $this->HT->query($sql, array($im_ic_id, $im_key));
|
|
|
|
return $query->result();
|
|
|
|
}
|
|
|
|
|
|
|
|
//获取未收录的信息
|
|
|
|
public function get_unembody_content($datetime, $top_num = 1) {
|
|
|
|
$sql = " SELECT TOP $top_num
|
|
|
|
im_ic_id,
|
|
|
|
im_value,
|
|
|
|
ic_url,
|
|
|
|
ic_sitecode,
|
|
|
|
log_ht_usercode AS ic_author
|
|
|
|
FROM infoMetas
|
|
|
|
INNER JOIN infoStructures ON is_ic_id=im_ic_id
|
|
|
|
INNER JOIN infoContents ON ic_id=im_ic_id
|
|
|
|
INNER JOIN infologs ON log_res_id=is_id
|
|
|
|
WHERE im_key = 'meta_embody'
|
|
|
|
AND convert(varchar(500),im_value) != '1'
|
|
|
|
AND convert(varchar(500),im_value)<N?
|
|
|
|
ORDER BY im_id DESC";
|
|
|
|
$query = $this->HT->query($sql, array($datetime));
|
|
|
|
return $query->result();
|
|
|
|
}
|
|
|
|
|
|
|
|
function update($im_ic_id, $im_key, $im_value) {
|
|
|
|
$sql = "UPDATE infoMetas \n"
|
|
|
|
. "SET im_value = N? \n"
|
|
|
|
. "WHERE im_ic_id = ? \n"
|
|
|
|
. " AND im_key = ?";
|
|
|
|
return $this->HT->query($sql, array($im_value, $im_ic_id, $im_key));
|
|
|
|
}
|
|
|
|
|
|
|
|
function delete($im_ic_id, $im_key) {
|
|
|
|
$sql = "DELETE \n"
|
|
|
|
. "FROM infoMetas \n"
|
|
|
|
. "WHERE im_ic_id = ? \n"
|
|
|
|
. " AND im_key = ?";
|
|
|
|
return $this->HT->query($sql, array($im_ic_id, $im_key));
|
|
|
|
}
|
|
|
|
|
|
|
|
function update_by_id($im_id, $im_value) {
|
|
|
|
$sql = "UPDATE infoMetas \n"
|
|
|
|
. "SET im_value = N? \n"
|
|
|
|
. "WHERE im_id = ? \n";
|
|
|
|
return $this->HT->query($sql, array($im_value, $im_id));
|
|
|
|
}
|
|
|
|
|
|
|
|
function delete_by_id($im_id) {
|
|
|
|
$sql = "DELETE \n"
|
|
|
|
. "FROM infoMetas \n"
|
|
|
|
. "WHERE im_id = ? \n";
|
|
|
|
return $this->HT->query($sql, array($im_id));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|