🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
~~~ <?php /*********************/ /* */ /* Version : 1.1.0 */ /* Author : DK */ /* Comment : 20140630 */ /* */ /*********************/ $mysqli = new mysqli('127.0.0.1','root','123456','vote'); $appid = 'wx49b2a7cd405b6cc3'; $sql = "select * from wx_config where appid = '$appid'"; $result = $mysqli->query($sql); while($row = $result->fetch_assoc()){ $arr = $row; } if($arr){ $update_time = $arr['update_time']; $time = time(); if(($time - 7000) > $arr['update_time']){ //更新 $sql = "update wx_config set access_token = '$access_token',update_time = $time where appid = '$appid'"; $rs = $mysqli->query($sql); if($mysqli->affected_rows){ return true; }else{ return false; } }else{ return true; } }else{ $time = time(); $sql = "insert into wx_config(appid,access_token,create_time,update_time) values('$appid', '$access_token', $time,$time)"; $rs = $mysqli->query($sql); if($mysqli->insert_id){ return true; }else{ return false; } } ?> ~~~