function fill_with_random_data() { $gen = new LoremIpsumGenerator('lorem.txt'); $iterations = 10; $rows_per_iteration = 10000; $connection = db_connect(); while ($iterations--) { $query = "INSERT INTO goods (`name`, `description`, `price`, `imgurl`) VALUES "; for ($i = 0; $i < $rows_per_iteration; $i++) { $item = []; $item['name'] = ucfirst(trim($gen->get_sentence())); $item['description'] = trim($gen->get_paragraph()); $item['price'] = rand(1, 10000000) / 100; $item['imgurl'] = get_random_img_name(); $query .= "('{$item['name']}', '{$item['description']}', '{$item['price']}', '{$item['imgurl']}')"; if ($i + 1 != $rows_per_iteration) { $query .= ","; } } $result = mysqli_query($connection, $query); if (!$result) { die('query error: ' . mysqli_error($connection)); } } }