<?php 
class Index_Model extends Model{
	function __construct(){
		parent::__construct();
	}
	function addClick($channelid,$contentid){
		$channel	=	$this->db->where("channel_id",$channelid)->join("model as m","c.model_id","m.model_id")->get("channel as c")->current();
		//搜索幻存
		$search		=	$this->db->where("channel_id",$channelid)->where("content_id",$contentid)->get("search_cache")->current();
		$this->db->where("channel_id",$channelid)->where("content_id",$contentid)->update("search_cache",array("click"=>$search->click+1));
		$this->db->where("channel_id",$channelid)->where("content_id",$contentid)->update($channel->model_value."_content",array("click"=>$search->click+1));
	}
	function countInstallSite($domain){
		if(!strpos(strtolower($domain),"localhost")){
			return $this->db->where("web_domain",$domain)->get("licence")->count();
		}
	}
	function getSite($domain){
		if(!strpos(strtolower($domain),"localhost")){
			return $this->db->where("web_domain",$domain)->get("licence")->current();
		}
		return false;
	}
	function updateInstallSite($domain,$data){
		return $this->db->where("web_domain",$domain)->update("licence",$data);
	}
	function addInstallSite($data){
		return $this->db->insert("licence",$data);
	}
}