TP3.2统计接口访问时长

field('id,spendcount,request,maxrequest,minrequest')
   ->where("url='%s'",$url_info)
   ->find();
if(!empty($url)){
   $times = round(microtime(true)-BEGIN_TIME,3);
   $serd['spendcount']  =$url['spendcount'] + 1;
   $serd['request']     =$url['request'] + 1;
   $serd['create_time'] = time();
   $serd['minrequest']  = $times;
   $serd['maxrequest']  = $url['maxrequest'] > $url['minrequest'] ? $url['maxrequest'] : $url['minrequest'];
   M('SendCount')->where('id='.$url['id'].'')->save($serd);
}else{
   $times = round(microtime(true)-BEGIN_TIME,3);
   $serd['spendcount']  = 1;
   $serd['url']         = $url_info;
   $serd['request']     = $times;
   $serd['minrequest']  = $times;
   $serd['create_time'] = time();
   $serd['type']        = 2;
   M('SendCount')->add($serd);
}

入口文件需设置:
define('BEGIN_TIME',microtime(true));

本文标题:TP3.2统计接口访问时长
浏览路径:http://csdahua.cn/article/gicjod.html
扫二维码与项目经理沟通

我们在微信上24小时期待你的声音

解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流