Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $text = [
- "Cory",
- "Calvin",
- "Jamie",
- "Rosie",
- "William",
- "Mary",
- "Joe",
- "Rene",
- "Abraham",
- "Jared",
- "Gregory",
- "Hazel",
- "Bradley",
- "Rhonda",
- "Alaina",
- "Donna",
- "Pamela",
- "Barb",
- "Jack",
- "Randi",
- "Donald",
- "Hattie",
- "Richard",
- "Randi",
- "Mozelle",
- "Martha",
- "Herman",
- "Mary",
- "Renee",
- "Thomas",
- "Charles",
- "Maria",
- "Jason",
- "Sylvia",
- "Bridget",
- "Timothy",
- "Norris",
- "Cynthia",
- "Kimberly",
- "Jeffery",
- "Kari",
- "Celia",
- "Margaret",
- "Jennifer",
- "Evelyn",
- "Dale",
- "Angela",
- "Rafael",
- "Jacquelyn",
- "Steven"
- ];
- $dummyScoutDataQuery = "INSERT INTO scout_data (name, match_number,
- team, robot_moved, auto_balls_crossed, auto_balls_high,
- auto_balls_low, teleop_balls_high, teleop_balls_low,
- robot_defended, end_game, rating, score, comments)
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
- if ($stmt = $db->prepare($dummyScoutDataQuery)) {
- for ($i = 0; $i < 50; $i++) {
- switch (rand(0, 2)) {
- case 0:
- $endGame = "none";
- break;
- case 1:
- $endGame = "scaling";
- break;
- case 2:
- $endGame = "challenging";
- break;
- }
- $stmt->bind_param("siiiiiiiiisiis",
- $text[$i],
- $i + 1,
- rand(1, 100) <= 15 ? 3506 : rand(1, 6000),
- rand(0, 1),
- rand(0, 6),
- rand(0, 6),
- rand(0, 6),
- rand(0, 6),
- rand(0, 6),
- rand(0,1),
- $endGame,
- rand(0, 6),
- rand(0, 6),
- generateRandomString(rand(10, 20)));
- $stmt->execute();
- $insert_id = $stmt->insert_id;
- $dummyDefenseQuery = "INSERT INTO `defenses` (`id`, `gametime`, `low_bar`, `portcullis`, `cheval_de_frise`, `moat`, `ramparts`, `drawbridge`, `sally_port`, `rock_wall`, `rough_terrain`) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
- if($defense_stmt = $db->prepare($dummyDefenseQuery)) {
- //stupid stupid php
- $auto = "auto";
- $defense_stmt->bind_param("isiiiiiiiii", $insert_id,
- $auto,
- rand(0, 3),
- rand(0, 3),
- rand(0, 3),
- rand(0, 3),
- rand(0, 3),
- rand(0, 3),
- rand(0, 3),
- rand(0, 3),
- rand(0, 3));
- $defense_stmt->execute();
- } else {
- header('HTTP/1.1 500 SQL Error', true, 500);
- $db->close();
- die ( '{"message":"Failed creating defenses statement"}' );
- }
- if($defense_stmt = $db->prepare($dummyDefenseQuery)) {
- //stupid stupid php
- $teleop = "teleop";
- $defense_stmt->bind_param("isiiiiiiiii", $insert_id,
- $teleop,
- rand(0, 3),
- rand(0, 3),
- rand(0, 3),
- rand(0, 3),
- rand(0, 3),
- rand(0, 3),
- rand(0, 3),
- rand(0, 3),
- rand(0, 3));
- $defense_stmt->execute();
- } else {
- header('HTTP/1.1 500 SQL Error', true, 500);
- $db->close();
- die ( '{"message":"Failed creating defenses statement"}' );
- }
- }
- } else {
- header('HTTP/1.1 500 SQL Error', true, 500);
- $db->close();
- die('{"message":"'.$stmt->error.'"}');
- }
- function generateRandomString($length = 10) {
- $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
- $charactersLength = strlen($characters);
- $randomString = '';
- for ($i = 0; $i < $length; $i++) {
- $randomString .= $characters[rand(0, $charactersLength - 1)];
- }
- return $randomString;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement