Skip to content

Instantly share code, notes, and snippets.

@Llewellynvdm
Last active May 28, 2020 23:40
Show Gist options
  • Save Llewellynvdm/a4224896d4337717e5d56b48e704052e to your computer and use it in GitHub Desktop.
Save Llewellynvdm/a4224896d4337717e5d56b48e704052e to your computer and use it in GitHub Desktop.
Little SQL generator in PHP
<?php
$surnames = array(
"SMITH",
"JOHNSON",
"WILLIAMS",
"BROWN",
"JONES",
"GARCIA",
"MILLER",
"DAVIS",
"RODRIGUEZ",
"MARTINEZ",
"HERNANDEZ",
"LOPEZ",
"GONZALEZ",
"WILSON",
"ANDERSON",
"THOMAS",
"TAYLOR",
"MOORE",
"JACKSON",
"MARTIN",
"LEE",
"PEREZ",
"THOMPSON",
"WHITE",
"HARRIS",
"SANCHEZ",
"CLARK",
"RAMIREZ",
"LEWIS",
"ROBINSON",
"WALKER",
"YOUNG",
"ALLEN",
"KING",
"WRIGHT",
"SCOTT",
"TORRES",
"NGUYEN",
"HILL",
"FLORES",
"GREEN",
"ADAMS",
"NELSON",
"BAKER",
"HALL",
"RIVERA",
"CAMPBELL",
"MITCHELL",
"CARTER",
"ROBERTS",
"GOMEZ",
"PHILLIPS",
"EVANS",
"TURNER",
"DIAZ",
"PARKER",
"CRUZ",
"EDWARDS",
"COLLINS",
"REYES",
"STEWART",
"MORRIS",
"MORALES",
"MURPHY",
"COOK",
"ROGERS",
"GUTIERREZ",
"ORTIZ",
"MORGAN",
"COOPER",
"PETERSON",
"BAILEY",
"REED",
"KELLY",
"HOWARD",
"RAMOS",
"KIM",
"COX",
"WARD",
"RICHARDSON",
"WATSON",
"BROOKS",
"CHAVEZ",
"WOOD",
"JAMES",
"BENNETT",
"GRAY",
"MENDOZA",
"RUIZ",
"HUGHES",
"PRICE",
"ALVAREZ",
"CASTILLO",
"SANDERS",
"PATEL",
"MYERS",
"LONG",
"ROSS",
"FOSTER",
"JIMENEZ",
"POWELL",
"JENKINS",
"PERRY",
"RUSSELL",
"SULLIVAN",
"BELL",
"COLEMAN",
"BUTLER",
"HENDERSON",
"BARNES",
"GONZALES",
"FISHER",
"VASQUEZ",
"SIMMONS",
"ROMERO",
"JORDAN",
"PATTERSON",
"ALEXANDER",
"HAMILTON",
"GRAHAM",
"REYNOLDS",
"GRIFFIN",
"WALLACE",
"MORENO",
"WEST",
"COLE",
"HAYES",
"BRYANT",
"HERRERA",
"GIBSON",
"ELLIS",
"TRAN",
"MEDINA",
"AGUILAR",
"STEVENS",
"MURRAY",
"FORD",
"CASTRO",
"MARSHALL",
"OWENS",
"HARRISON",
"FERNANDEZ",
"MCDONALD",
"WOODS",
"WASHINGTON",
"KENNEDY",
"WELLS",
"VARGAS",
"HENRY",
"CHEN",
"FREEMAN",
"WEBB",
"TUCKER",
"GUZMAN",
"BURNS",
"CRAWFORD",
"OLSON",
"SIMPSON",
"PORTER",
"HUNTER",
"GORDON",
"MENDEZ",
"SILVA",
"SHAW",
"SNYDER",
"MASON",
"DIXON",
"MUNOZ",
"HUNT",
"HICKS",
"HOLMES",
"PALMER",
"WAGNER",
"BLACK",
"ROBERTSON",
"BOYD",
"ROSE",
"STONE",
"SALAZAR",
"FOX",
"WARREN",
"MILLS",
"MEYER",
"RICE",
"SCHMIDT",
"GARZA",
"DANIELS",
"FERGUSON",
"NICHOLS",
"STEPHENS",
"SOTO",
"WEAVER",
"RYAN"
);
$names = array(
"JAMES",
"JOHN",
"ROBERT",
"MICHAEL",
"WILLIAM",
"DAVID",
"RICHARD",
"CHARLES",
"JOSEPH",
"THOMAS",
"CHRISTOPHER",
"DANIEL",
"PAUL",
"MARK",
"DONALD",
"GEORGE",
"KENNETH",
"STEVEN",
"EDWARD",
"BRIAN",
"RONALD",
"ANTHONY",
"KEVIN",
"JASON",
"MATTHEW",
"GARY",
"TIMOTHY",
"JOSE",
"LARRY",
"JEFFREY",
"FRANK",
"SCOTT",
"ERIC",
"STEPHEN",
"ANDREW",
"RAYMOND",
"GREGORY",
"JOSHUA",
"JERRY",
"DENNIS",
"WALTER",
"PATRICK",
"PETER",
"HAROLD",
"DOUGLAS",
"HENRY",
"CARL",
"ARTHUR",
"RYAN",
"ROGER",
"JOE",
"JUAN",
"JACK",
"ALBERT",
"JONATHAN",
"JUSTIN",
"TERRY",
"GERALD",
"KEITH",
"SAMUEL",
"WILLIE",
"RALPH",
"LAWRENCE",
"NICHOLAS",
"MARY",
"PATRICIA",
"LINDA",
"BARBARA",
"ELIZABETH",
"JENNIFER",
"MARIA",
"SUSAN",
"MARGARET",
"DOROTHY",
"LISA",
"NANCY",
"KAREN",
"BETTY",
"HELEN",
"SANDRA",
"DONNA",
"CAROL",
"RUTH",
"SHARON",
"MICHELLE",
"LAURA",
"SARAH",
"KIMBERLY",
"DEBORAH",
"JESSICA",
"SHIRLEY",
"CYNTHIA",
"ANGELA",
"MELISSA",
"BRENDA",
"AMY",
"ANNA",
"REBECCA",
"VIRGINIA",
"KATHLEEN",
"PAMELA",
"MARTHA",
"DEBRA",
"AMANDA",
"STEPHANIE",
"CAROLYN",
"CHRISTINE",
"MARIE",
"JANET",
"CATHERINE",
"FRANCES",
"ANN"
);
function randomLetter($size)
{
$bag = "A BC DEF G HIJKLL MNOP QRS TUV W XUZ ";
$key = array();
$bagsize = strlen($bag) - 1;
for ($i = 0; $i < $size; $i++)
{
$get = rand(0, $bagsize);
$key[] = $bag[$get];
}
return implode($key);
}
function randomNumber($size)
{
$bag = "0987654321877";
$key = array();
$bagsize = strlen($bag) - 1;
for ($i = 0; $i < $size; $i++)
{
$get = rand(0, $bagsize);
$key[] = $bag[$get];
}
return implode($key);
}
function randomL($size)
{
$bag = "111110111111000";
$key = array();
$bagsize = strlen($bag) - 1;
for ($i = 0; $i < $size; $i++)
{
$get = rand(0, $bagsize);
$key[] = $bag[$get];
}
return implode($key);
}
$ns = count($names) - 1;
$ss = count($surnames) - 1;
$keys = array();
for ($i = 0; $i < 300; $i++){
$n = rand(0, $ns);
$s = rand(0, $ss);
$l = trim(randomLetter(1));
if (strlen($l))
{
$l = " " . $l . ". ";
} else {
$l = " ";
}
$randomNumber = randomNumber(6);
while (isset($keys[$randomNumber])){
$randomNumber = randomNumber(6);
}
$keys[$randomNumber] = $randomNumber;
echo "INSERT INTO [Employee] (Number, Name, DateOfHire, DateOfBirth, CommercialDriverLicense)<br />";
echo "VALUES (". $randomNumber .", '".
ucfirst(strtolower($names[$n])) . $l . ucfirst(strtolower($surnames[$s])) .
"', '20" . rand(0, 1) . rand(0, 9) . "-" . rand(1, 12) . "-" . rand(1, 26) .
"', '19" . rand(74, 95) . "-" . rand(1, 12) . "-" . rand(1, 26) .
"', " . randomL(1) . ")<br />";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment