添加 infoTags 模型

hotfix/远程访问多媒体中心
lmr@hainatravel.com 8 years ago
parent 15fbaebf23
commit f37b965cc4

@ -0,0 +1,90 @@
<?php
class InfoTags_model extends CI_Model
{
//信息标签表
var $it_title = '';
var $it_memu = '';
//信息标签关联表
var $ic_id = '';
var $it_id = '';
function __construct()
{
parent::__construct();
$this->HT = $this->load->database('HT', TRUE);
}
/**
* 增加标签
*/
function add_tag()
{
if ($this->it_title)
{
//查看是否已存在标签
$sql = "SELECT TOP 1 * from infoTags WHERE ic_title = N?";
$check = $this->HT->query($sql, array($this->it_title));
//添加标签
if ($query->num_rows() === 0)
{
$sql = "INSERT INTO infoTags (it_title, it_memo) VALUES (N?, N?)";
$query = $this->HT->query($sql, array($this->it_title, $this->it_memu));
}
return true;
}
return false;
}
/**
* 删除标签
*/
function remove_tag()
{
if ($this->it_title)
{
$sql = "DELETE FROM infoTags WHERE it_title = N?";
$query = $this->HT->query($sql, array($this->it_title));
return true;
}
return false;
}
/**
* 添加信息与标签的关联
*/
function add_tag_to_content()
{
if ($this->ic_id && $this->it_id)
{
//查看是否已存在关联
$sql = "SELECT TOP 1 * from infoContentToTag WHERE ic_id = ? AND it_id = ?";
$check = $this->HT->query($sql, array($this->ic_id, $this->it_id));
//添加关联
if ($query->num_rows() === 0)
{
$sql = "INSERT INTO infoContentToTag (ic_id, it_id) VALUES (?, ?)";
$query = $this->HT->query($sql, array($this->ic_id, $this->it_id));
}
return true;
}
return false;
}
/**
* 解除信息与标签的关联
*/
function remove_tag_to_content()
{
if ($this->ic_id && $this->it_id)
{
$sql = "DELETE FROM infoContentToTag WHERE ic_id = ? and it_id = ?";
$query = $this->HT->query($sql, array($this->ic_id, $this->it_id));
return true;
}
return false;
}
}
Loading…
Cancel
Save