首页 > 代码库 > 插入数据库 每次1000条数据

插入数据库 每次1000条数据

  $sql = "insert into `elconlist` (`ecgrouid`,`elcono`) VALUES";            for($i = 0; $i < $ecnum; $i++){                //拼装SQL                if($i != $ecnum-1){                    if((float)($i+1)%1000 != 0){                        $sql .= "(".$ecgrouid.",‘".$this->creatElcono($comid)."‘),";                    }else{                        $sql .= "(".$ecgrouid.",‘".$this->creatElcono($comid)."‘)";                    }                }else{                    $sql .= "(".$ecgrouid.",‘".$this->creatElcono($comid)."‘)";                }                if((float)($i+1)%1000 == 0 ){                    $model->execute($sql);                    $sql = "insert into `elconlist` (`ecgrouid`,`elcono`) VALUES";                }else{                    if($i == $ecnum-1){                        $model->execute($sql);                        $sql = "insert into `elconlist` (`ecgrouid`,`elcono`) VALUES";                    }                }            }