Skip to content

Instantly share code, notes, and snippets.

@hobodave
Created January 25, 2012 19:14
Show Gist options
  • Save hobodave/1677983 to your computer and use it in GitHub Desktop.
Save hobodave/1677983 to your computer and use it in GitHub Desktop.
<?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