LaundroMat
Programmer
Hi, I'm initializing a database with random numbers, and I noticed INSERTing the data into my mySQL database does take quite some time (especially considering the amount of data I want to enter).
Here's the script:
Now, for a SIZE_X and SIZE_Y of 10 each, 100 INSERT queries have been sent. This takes some time... What would be the fastest way of doing this?
Thanks in advance!
Here's the script:
Code:
for ($x = 1; $x <= SIZE_X ; $x++) {
for ($y = 1; $y <= SIZE_Y ; $y++) {
$amt = mt_rand(MIN_AMOUNT, MAX_AMOUNT);
$r = $amt*mt_rand(0,100);
$g = $amt*(mt_rand(0,100-$r));
$b = $amt*(100-$r-$g);
$sql = "INSERT INTO tile (x, y, r, g, b) VALUES ($x, $y, $r, $g, $b)";
$db->query($sql);
}
}
Now, for a SIZE_X and SIZE_Y of 10 each, 100 INSERT queries have been sent. This takes some time... What would be the fastest way of doing this?
Thanks in advance!