Created
January 25, 2012 19:14
-
-
Save hobodave/1677983 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$conn = new PDO('mysql:dbname=test;host=localhost', 'hobodave', 'hobodave'); | |
$sql = <<<SQL | |
INSERT INTO rocketships (nose_id, num_fueltanks, name, manager_id, fuselage_id, fuel_type, created_at) | |
VALUES | |
SQL; | |
$vals = ''; | |
$fuel_types = array( | |
'water', | |
'diesel', | |
'propane', | |
'apcp', | |
'solid', | |
'magic', | |
); | |
for($i = 0; $i < 10000000; $i++) { | |
$vals .= '('; | |
$nose_id = rand(1,10); | |
$num_fueltanks = rand(1,8); | |
$name = 'Whatever'; | |
$manager_id = rand(1,25); | |
$fuselage_id = rand(1,6); | |
$fuel_type = $fuel_types[rand(0,5)]; | |
$time = rand( strtotime("Jan 01 2000"), strtotime("Dec 31 2009")); | |
$created_at = date('Y-m-d H:i:s', $time); | |
$vals .= "$nose_id, $num_fueltanks, '$name', $manager_id, $fuselage_id, '$fuel_type', '$created_at'),"; | |
if ($i % 1000 == 0) { | |
$vals = rtrim($vals, ','); | |
$conn->exec($sql . $vals); | |
$vals = ''; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment