• php 批量导入昨天的数据(别类版的增量备份安案)


    $where = '';
                $localogLogin = $this->gamedb_model->query_onerow("select `datetime` from logLogin order by id desc");
                $posdatetime =     $localogLogin['datetime'];
                if(empty()){
                    $where = "where datetime<'$todaydate'";
                }else{
                    $where = "where datetime<'$todaydate' and datetime>'$posdatetime'";
                }
                $remountlist = $this->remotedb_model->query_onerow("select count(*) as num from logLogin $where");
                $allcount = $remountlist['num'];
                if($allcount){
                    $page = 1;//当前页
                    $pagesize=1000;//分页大小
                    $failt = 0;// 失败次数
                    $allpage =ceil($allcount/$pagesize);//分页总大小
                    while($page <= $allpage){
                            $sqltmp = 'insert  into `loglogin`(`accid`,`roleID`,`macAddr`,`ip`,`datetime`,`online`) values';
                            //一天一天的算
                            $templogdate = $this->remotedb_model->query_lists("select * from logLogin $where order by datetime asc limit ".($page-1)*$pagesize.",$pagesize");
                            foreach ($templogdate as $k => $val) {
                                    $tempdate = substr($val['datetime'],0,strpos($val['datetime']," "));
                                    if($k == (count($templogdate)-1)){
                                        $sqltmp .="($val[accid],$val[roleID],'$val[macAddr]','$val[ip]','$val[datetime]',$tempdate)";
                                    }else{
                                        $sqltmp .="($val[accid],$val[roleID],'$val[macAddr]','$val[ip]','$val[datetime]',$tempdate),";
                                    }
                            }
                            $this->gamedb_model->query($sqltmp);
                            $sqltmp = '';
                            $page++;
                        }
                }
    $localogLogin = $this->gamedb_model->query_onerow("select id from logLogin order by id desc");
                $maxid = empty($localogLogin['id'])?'0':$localogLogin['id'];
                $remountlist = $this->remotedb_model->query_onerow("select count(*) as num from logLogin where id>$maxid");                
                $allcount = $remountlist['num'];
                if($allcount){
                    $page = 1;//当前页
                    $pagesize=1000;//分页大小
                    $failt = 0;// 失败次数
                    $allpage =ceil($allcount/$pagesize);//分页总大小
                    while($page <= $allpage){
                            $sqltmp = 'insert  into `loglogin`(`accid`,`roleID`,`macAddr`,`ip`,`datetime`,`online`) values';
                            //一天一天的算
                            $templogdate = $this->remotedb_model->query_lists("select * from logLogin where id>$maxid order by id asc limit ".($page-1)*$pagesize.",$pagesize");
                            foreach ($templogdate as $k => $val) {
                                
                                    $tempdate = substr($val['datetime'],0,strpos($val['datetime']," "));
                                    
                                    if($k == (count($templogdate)-1)){
                                        $sqltmp .="($val[accid],$val[roleID],'$val[macAddr]','$val[ip]','$val[datetime]',$tempdate)";
                                    }else{
                                        $sqltmp .="($val[accid],$val[roleID],'$val[macAddr]','$val[ip]','$val[datetime]',$tempdate),";
                                    }
                            }
    
                            $this->gamedb_model->query($sqltmp);
                            $sqltmp = '';
                            $page++;
                        }
                }
  • 相关阅读:
    char *s 和char s[]的区别
    Loadrunner时间函数、用时间生成订单编号例子
    loadrunner获取毫秒及字符串替换实现
    关联的特殊应用
    LR中的时间戳函数web_save_timestamp_param
    使用 If-Then-Else 逻辑进行分支
    ArcGIS中国工具3.2新功能
    运行模型,COM错误,解决问题步骤
    arcgis python 更新日期为随机数
    使用LAS数据集创建DEM和DSM
  • 原文地址:https://www.cnblogs.com/jackluo/p/3383109.html
Copyright © 2020-2023  润新知