<?php 
namespace Common\Model;
use Think\Model;
class UserFavoritesModel extends Model
{
	//统计关注数量
 	public function get_favorites_count($objid='',$type='1')
	{
		$map['objid']=intval($objid);
		$map['type']=intval($type);
		$count=$this->where($map)->count();
		return $count;
	}
	//检测是否收藏
	public function chenk_favorites($uid='',$objid='',$type='')
	{
		$map['type']=intval($type);
		$map['uid']=intval($uid);
		$map['objid']=intval($objid);
		$n=$this->where($map)->count();
		if ($n)
		{
		return true;
		}
		return false;  
	}
 	//加入收藏
	public function add_favorites($uid='',$objid='',$type='')
	{
		$data['uid']=intval($uid);
		$data['objid']=intval($objid);
		$data['type']=intval($type);
		$data['addtime']=time();
		$this->add($data);
		return true;  
	}
	//取消收藏
	public function clear_favorites($uid='',$objid='',$type='')
	{
		$map['uid']=intval($uid);
		$map['objid']=intval($objid);
		$map['type']=intval($type);
		$this->where($map)->delete();
		return true;  
	}
}
?>