数据库查询:比较两个字段值的大小区间集合
业务需求:关联查询两张表,查出关注的人的关注日期之后的发布的动态数据,之前的看不到,所以,关联查询再发布日期大于关注日期即可,但是,where('fabu_time','>','guanzhu_time')这样是不行的,查不到,要这么写才行:
where('`fabu_time` > `guanzhu_time`');//这个 '`' 千万不能丢即可
业务需求:关联查询两张表,查出关注的人的关注日期之后的发布的动态数据,之前的看不到,所以,关联查询再发布日期大于关注日期即可,但是,where('fabu_time','>','guanzhu_time')这样是不行的,查不到,要这么写才行:
where('`fabu_time` > `guanzhu_time`');//这个 '`' 千万不能丢即可
根据经纬度计算出两地之间的距离,两种,一种是在数据库查询语句,一种是PHP计算
1、SQL语句(PS:a小o大)
ROUND(6378.138 * 2 * ASIN(SQRT(POW(SIN(('.用户位置lat.'* PI() / 180 - 数据库lat字段 * PI() / 180) / 2),2) + COS('.用户位置lat.' * PI() / 180) * COS(数据库lat字段 * PI() / 180) * POW(SIN(('.用户位置lon.' * PI() / 180 - 数据库lon字段 * PI() / 180) / 2),2))) * 1000) AS distance2、PHP计算
function getDistance($lat1, $lng1, $lat2, $lng2){
//将角度转为狐度
$radLat1=deg2rad($lat1);//deg2rad()函数将角度转换为弧度
$radLat2=deg2rad($lat2);
$radLng1=deg2rad($lng1);
$radLng2=deg2rad($lng2);
$a=$radLat1-$radLat2;
$b=$radLng1-$radLng2;
$s=2*asin(sqrt(pow(sin($a/2),2)+cos($radLat1)*cos($radLat2)*pow(sin($b/2),2)))*6378.137;
$res = round($s*1000);
if($res < 1000){
return $res . 'm';
}else{
return round($res/1000,2) . 'km';
}
} 在centos7中用iptables命令配置完策略规则后,需要保存策略永久生效,执行service iptables save时提示错误如下:
# service iptables save
The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl.先执行如下命令:
systemctl stop firewalld
systemctl mask firewalld安装iptables services
yum install iptables-services设置开机启动
systemctl enable iptables重启iptables service
systemctl restart iptables就可以执行保存配置命令了:
service iptables save下载apk文件直接a链接即可,下面是用header下载文件,apk会显示HTML,乱码。。。
<?php
header("Content-Type:text/html; charset=utf-8");
if(get_device_type()=='ios'){
$ff='huanbaoba.ipa';
header('application/iphone'); ios专属现在头文件
header('Content-Disposition:attachment;filename="huanbaoba.ipa"');
}else{
$ff='huanbaoba.apk';
header('application/vnd.android.package-archive');
header('Content-Disposition:attachment;filename="huanbaoba.apk"');
}
readfile($ff);
//获取设备类型
function get_device_type(){
$agent = strtolower($_SERVER['HTTP_USER_AGENT']);
$type = 'other';
if(strpos($agent, 'iphone') || strpos($agent, 'ipad')){
$type = 'ios';
}
if(strpos($agent, 'android')){
$type = 'android';
}
return $type;
} 是不是微信端打开网页
一:js判断设备类型
function is_weixn(){
var ua = navigator.userAgent.toLowerCase();
if(ua.match(/MicroMessenger/i)=="micromessenger") { //判断是否在微信中打开此网页
return true;
} else {
return false;
}
} 二: php判断设备及浏览器等等类型
function is_weixin(){
if ( strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false ) {
return true;
}
return false;
} function deldir($dir) {
$dh=opendir($dir);
while ($file=readdir($dh)) {
if($file!="." && $file!="..") {
$fullpath=$dir.'/'.$file;
if(!is_dir($fullpath)) {
unlink($fullpath);
} else {
$this->systemInfoSafe($fullpath);
}
}
}
closedir($dh);
if(rmdir($dir)) {
return true;
} else {
return false;
}}