$countkey=$_GET['key'];//获取要操作的计数key
if($countkey=="") exit;
if($_GET['action']=="add"){
$cou=new counter($countkey);
$cou->inc();//计数key对应的值加1
}elseif($_GET['action']=="get"){
$cou=new counter($countkey);
echo $cou->get();
}
class counter {
private $kvdb;
private $key;
public function __construct($key){
$this->kvdb=new CKvdb();
$this->key=$key;
}
public function inc(){
$num=$this->kvdb->get($this->key)+1;
$this->kvdb->set($this->key,$num);
return $num;
}
public function dec(){
$num=$this->kvdb->get($this->key)-1;
$this->kvdb->set($this->key,$num);
return $num;
}
public function get(){
$num=$this->kvdb->get($this->key);
return intval($num);
}
}
class CKvdb //这个类封装的kvdb操作。
{
private $db;
function __construct(){
$this->db=new SaeKv();
$this->db->init();
}
public function set($key,$value)
{
$this->db->set($key,$value);
}
public function get($key)
{
return $this->db->get($key);
}
}
var keyTemp = $('#postTemp').text();
$.get('http://localhost/counter.php',{ action:'add',key:keyTemp });
$.get('http://localhost/counter.php',{ action:'get',key:keyTemp },function(data){
$('#view').text(data+' Views');
});
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有