zoukankan      html  css  js  c++  java
  • 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++;
                        }
                }
  • 相关阅读:
    Springboot 基于的SAP项目环境配置
    Impala 技术点梳理
    Elasticsearch 使用技巧笔记
    ELK 6.x 部署
    eclipse安装lombok
    IIS服务器管理学习
    Springboot依赖注入笔记
    Eclipse解决乱码问题
    Springboot依赖注入 Service类中使用静态变量
    javascript 操作符类型隐性转换
  • 原文地址:https://www.cnblogs.com/jackluo/p/3383109.html
Copyright © 2011-2022 走看看