<?php
class FeedbackModel extends DBModel {
	public function init(){
	}
	/*
	提交报告
	*/
	public function report($POST){	
		if (!$POST['contents']){
			$this->error = _('请填写报告内容!');
			return false;
		}
		$data = array();
		$data['title'] = strip_tags($POST['title']);
		$data['movid'] = (int)$POST['movid'];
		$data['username'] = strip_tags($POST['username']);
		$data['contents'] = strip_tags($POST['contents']);
		$data['addtime'] = time();
		$data['isread'] = 0;
		if ((int)$POST['movid']){
			$sql = 'UPDATE '.VODCMS_MOVIE.' set report=report+1 WHERE movid='.(int)$POST['movid'];
			$this->_DB->exec($sql);
		}
		return $this->_DB->insert(VODCMS_FEEDBACK, $data);
	}
	public function  getAll($where=null){
		$select = $this->_DB->select();
		$sql = $select->from(VODCMS_FEEDBACK)->where($where)->toString();
		$total = $this->_DB->getCount($sql);
		$this->_Page->set($total);
		$this->printPage = $this->_Page->PrintPage();
		return $this->_DB->fetAll($sql.$this->_Page->limit());
	}
	public function delete($id){
		if (is_array($id)){
			$id = implode(',', array_map('intval', $id));
		}
		return $this->_DB->delete(VODCMS_FEEDBACK, 'id in ('.$id.')');
	}
	public function getRow($id){
		$select = $this->_DB->select();
		$sql = $select->from(VODCMS_FEEDBACK)->where(array('id'=>(int)$id))->toString();
		return $this->_DB->fetRow($sql);
	}
	public function setRead($id){
		return $this->_DB->update(VODCMS_FEEDBACK, array('isread'=>1), array('id'=>(int)$id));
	}
}?>