mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-07-02 10:34:31 +00:00
refactor: much speedier installation process
This commit is contained in:
@@ -20,6 +20,8 @@ if (count($data_exist)) {
|
||||
}
|
||||
|
||||
$xyas=(1+(2*WORLD_MAX));
|
||||
$values_batch = [];
|
||||
$max_batch_size = 10000;
|
||||
|
||||
for($i=0; $i<$xyas; $i++){
|
||||
$y=(WORLD_MAX-$i);
|
||||
@@ -115,11 +117,24 @@ $y=(WORLD_MAX-$i);
|
||||
}
|
||||
|
||||
//into database
|
||||
$q = "INSERT into ".TB_PREFIX."wdata values (0,'".$typ."','".$otype."','".$x."','".$y."',0,'".$image."')";
|
||||
$database->query($q);
|
||||
$values_batch[] = "(0,'".$typ."','".$otype."','".$x."','".$y."',0,'".$image."')";
|
||||
|
||||
// insert the full batch when threshold is reached
|
||||
if (count($values_batch) === $max_batch_size) {
|
||||
$q = "INSERT into ".TB_PREFIX."wdata VALUES ".implode(',', $values_batch);
|
||||
$database->query($q);
|
||||
$values_batch = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// last batch may not be as big as $max_batch_size
|
||||
if (count($values_batch)) {
|
||||
$q = "INSERT into ".TB_PREFIX."wdata VALUES ".implode(',', $values_batch);
|
||||
$database->query($q);
|
||||
$values_batch = [];
|
||||
}
|
||||
|
||||
header("Location: ../index.php?s=4");
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user