where(" uid = '%s' and date_month = '$month' " , array($uid))->find() ; if($file_flow){ return intval($file_flow['used']) ; }else{ D("FileFlow")->add(array( "uid" => $uid , "used" => 0 , "date_month" => $month , )); return 0 ; } } //记录某个用户流量 public function recordUserFlow($uid , $file_size){ $month = Date("Y-m") ; $used = $this->getUserFlow($uid) ; return D("FileFlow")->where(" uid = '%s' and date_month = '$month' " , array($uid))->save(array( "used" => $used + intval($file_size) )); } public function deleteFile($file_id){ $file = D("UploadFile")->where("file_id = '$file_id' ")->find(); $real_url = $file['real_url'] ; $array = explode("/Public/Uploads/", $real_url) ; $file_path = "../Public/Uploads/".$array[1] ; if (file_exists($file_path)) { @unlink($file_path); } D("UploadFile")->where(" file_id = '$file_id' ")->delete(); return true ; } }