Advertisement
Guest User

Untitled

a guest
Jun 14th, 2016
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. SELECT @username := "testuser1";
  2.  
  3. SELECT @first_name := "test";
  4.  
  5. SELECT @last_name := "user";
  6.  
  7. SELECT @email := "testuser1@testuser.com";
  8.  
  9. SELECT @password := "5f4dcc3b5aa765d61d8327deb882cf99";
  10.  
  11. SELECT @section_name := "testusersection1";
  12.  
  13. # Add a new section
  14. INSERT INTO `wags`.`section` (`id`, `name`, `administrator`, `logicalExercises`, `added`, `updated`) VALUES (NULL, @section_name, '1', NULL, '1', '1');
  15.  
  16. # Get the section number from the new section
  17. SELECT @section_number := (SELECT `id` FROM `section` WHERE name = @section_name);
  18.  
  19. # Add User
  20. INSERT INTO `wags`.`user` (`id`, `username`, `firstName`, `lastName`, `email`, `password`, `added`, `updated`, `lastLogin`, `admin`, `section`) VALUES (NULL, @username, @first_name, @last_name, @email, @password, '1', '1', '1', '1', @section_number);
  21.  
  22. # Get user id number
  23. SELECT @user_id_number := (SELECT `id` FROM `user` WHERE `username` = @username);
  24.  
  25. # Update admin on section that was created
  26. UPDATE `section` SET `administrator`= @user_id_number WHERE id = @section_number;
  27.  
  28. # Add magnet groups to section
  29. INSERT INTO `SectionMP` (`section`, `magnetP`)
  30. SELECT @section_number, `id`
  31. FROM `magnetProblem` WHERE `groupID` BETWEEN 2 AND 15;
  32.  
  33. # Add all problems from the above groups to section
  34. INSERT INTO `wags`.`SectionMPG` (`id`, `section`, `magnetGroup`) VALUES (NULL, @section_number, '2'), (NULL, @section_number, '3'), (NULL, @section_number, '4'), (NULL, @section_number, '5'), (NULL, @section_number, '6'), (NULL, @section_number, '7'), (NULL, @section_number, '8'), (NULL, @section_number, '9'), (NULL, @section_number, '10'), (NULL, @section_number, '11'), (NULL, @section_number, '12'), (NULL, @section_number, '13'), (NULL, @section_number, '14'), (NULL, @section_number, '15');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement