海运的博客

MySQL插入存在覆盖

发布时间:April 9, 2014 // 分类:数据库 // No Comments

1.当插入列为主健或单一索引(可多列)值重复时执行update操作:

INSERT INTO `records` (`domain_id`, `name`, `TYPE`, `content`, `ttl`) VALUES 
(:id, :name, :type, :content, :ttl) ON DUPLICATE KEY UPDATE `change_date` = '1';

2.重复时先删除之前数据再插入新数据:

REPLACE INTO `records` (`domain_id`, `name`, `TYPE`, `content`, `ttl`) VALUES 
(:id, :name, :type, :content, :ttl);

PHP使用GeoIP

发布时间:April 9, 2014 // 分类:PHP // No Comments

1.使用PHP GeoIP扩展,功能不全,如不能查询AS号:

yum install php-pecl-geoip
#下载最新geo数据库
cd /usr/share/GeoIP/
wget http://www.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
gzip -d GeoIP.dat.gz
<?php
echo geoip_country_code_by_name('www.haiyun.me') . "\n";
?>

2.使用GeoIP官方提供的PHP API,不可和上扩展共存,函数冲突。

git clone https://github.com/maxmind/geoip-api-php.git
<?php
include("./src/geoip.inc");
$gi = geoip_open("/usr/share/GeoIP/GeoIP.dat", GEOIP_STANDARD);
echo geoip_country_code_by_name($gi, "www.haiyun.me") . "\n";
?>

GeoIP数据库下载:http://dev.maxmind.com/geoip/legacy/geolite/

分类
最新文章
最近回复
  • 海运: 恩山有很多。
  • swsend: 大佬可以分享一下固件吗,谢谢。
  • Jimmy: 方法一 nghtp3步骤需要改成如下才能编译成功: git clone https://git...
  • 海运: 地址格式和udpxy一样,udpxy和msd_lite能用这个就能用。
  • 1: 怎么用 编译后的程序在家里路由器内任意一台设备上运行就可以吗?比如笔记本电脑 m参数是笔记本的...
  • 孤狼: ups_status_set: seems that UPS [BK650M2-CH] is ...
  • 孤狼: 擦。。。。apcupsd会失联 nut在冲到到100的时候会ONBATT进入关机状态,我想想办...
  • 海运: 网络,找到相应的url编辑重发请求,firefox有此功能,其它未知。
  • knetxp: 用浏览器F12网络拦截或监听后编辑重发请求,修改url中的set为set_super,将POS...
  • Albert: 啊啊啊啊啊啊啊啊啊 我太激动了,终于好了英文区搜索了半天,翻遍了 pve 论坛没找到好方法,博...