⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 commentsmodel.php

📁 a short sketch about linux syntex lines.
💻 PHP
字号:
<?php
/*
评论管理程序 
*/
class CommentsModel extends DBModel {
	/*
	评论发布
	*/
	public function Add($POST){
		//print_r($POST);
		IF (empty($POST['username'])){
			$this->error = _('评论人不能为空!');
			return false;
		}
		if (empty($POST['content'])){
			$this->error = _('请填写评论内容!');
			return false;
		}
		$POST['addtime'] = time();
		$this->_DB->insert(VODCMS_COMMENT, $POST);
		$this->_DB->update(VODCMS_MOVIE, 'review = review + 1', array('movid'=> (int)$POST['movid']));
		return $this->_DB->lastinsertid();
	}
	/*获取指定条件的评论内容*/
	public function getAll($where = null){
		$select = $this->_DB->select();
		$select->from(VODCMS_COMMENT);
		$select->where($where);
		$select->where('locked=0');
		$select->order('id DESC');
		$sql = $select->toString();
		$total = $this->_DB->getCount($sql);
		$this->_Page->set($total, 10);
		$this->printPage = $this->_Page->printBody();
		return $this->_DB->fetAll($sql.$this->_Page->limit());
	}
	/*后台获取指定条件的评论内容*/
	public function getList($where = null){
		$select = $this->_DB->select();
		$select->from(VODCMS_COMMENT);
		$select->where($where);
		$select->order('id DESC');
		$sql = $select->toString();
		$total = $this->_DB->getCount($sql);
		$this->_Page->set($total, 10);
		$this->printPage = $this->_Page->printpage();
		return $this->_DB->fetAll($sql.$this->_Page->limit());
	}
	/*删除一行评论同时影片评论数减一*/
	public function delete($id){
		if (is_array($id)){
			$array = $id;
		}else{
			$array = array($id);
		}
		foreach ( $array as $id){
			$row = $this->getRow($id);
			$movid = (int)$row['movid'];
			$this->_DB->update(VODCMS_MOVIE, 'review = review -1', array('movid'=> $movid));
			systemlog::set('删除了影片评论资料');
			$this->_DB->delete(VODCMS_COMMENT, array('id'=>(int)$id));
		}
		return true;
	}
	/*获取一行记录*/
	public function getRow($id){
		$select = $this->_DB->select();
		$select->from(VODCMS_COMMENT);
		$select->where(array('id'=>$id));
		$sql = $select->toString();
		return $this->_DB->fetRow($sql);
	}
	public function locked($id){
		if (is_array($id)){
			$where = implode(',', array_map('intval', $id));
		}else{
			$where = $id;
		}
		return $this->_DB->update(VODCMS_COMMENT, array('locked'=>0), 'id in ('.$where.')');
	}
	
}?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -