<?php
 /**
 *      [QKSHOP] (C) QIKEWEB Inc.
 *      This is NOT a freeware, use is subject to license terms
 */

class PostModel extends BaseModel{
	public $msg='';
	function add($params){
		$title = $params['title'];
		$name = $params['name'];
		$nickname = $params['nickname'];
		$mobile = $params['mobile'];
		$phone = $params['phone'];
		$qq = $params['qq'];
		$email = $params['email'];
		$homepage = $params['homepage'];
		$content = $params['content'];
		$goodsId = $params['goodsId'];
		$userId = $_SESSION['userId'];
		$serviceId = $params['serviceId'];
		$productCatId = $params['productCatId'];
		$catId = $params['catId'];if(!$catId || !is_numeric($catId)){$catId=0;}
		//if(!$userId){$this->msg='请登录后留言';return false;}
		if(!$content){$this->msg='请填写留言内容';return false;}
		if($content){
			if(!$userId){$userId=0;}
			$siteId="";if(defined('SITE_ID')){$siteId .= " ,siteId='".SITE_ID."'";}
			$sql = "insert into qk_post set ";
			$sql .= " title='$title',name='$name',phone='$phone',qq='$qq',email='$email',homepage='$homepage',content='$content',goodsId='$goodsId',userId='$userId'";
			$sql .= ",nickname='$nickname',mobile='$mobile',serviceId='$serviceId',productCatId='$productCatId',catId='$catId'";
			$sql .= ",posttime=UNIX_TIMESTAMP()".$siteId;
			if($this->db->query($sql)){
				$this->msg='留言成功';
				return true;
			}
		}

		return false;
	}
}
?>