diff --git a/application/models/infoTags_mode.php b/application/models/infoTags_mode.php new file mode 100644 index 00000000..b52a33bc --- /dev/null +++ b/application/models/infoTags_mode.php @@ -0,0 +1,90 @@ +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; + } + +}