delete_team.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /**
  3. * File for the team creation action.
  4. *
  5. * Implements an action function to be called from the {@see Controller}.
  6. *
  7. * @category Action
  8. */
  9. /**
  10. * Deletes a team.
  11. *
  12. * Reads the POST parameters looking for the following KEYS:
  13. * uid
  14. * id
  15. *
  16. * @return int 0 on success, negative values on error.
  17. * @category Action
  18. * @global resource Database connection.
  19. */
  20. function action(){
  21. global $db;
  22. $player = filter_input(INPUT_POST, 'uid');
  23. $id = filter_input(INPUT_POST, 'id');
  24. $statement = $db->prepare('DELETE FROM team WHERE uid = :uid AND id = :id;');
  25. $statement->bindValue(':uid', $player, SQLITE3_TEXT);
  26. $statement->bindValue(':id', $id, SQLITE3_TEXT);
  27. $statement->execute();
  28. $statement = $db->prepare('DELETE FROM team_unit WHERE team = :id;');
  29. $statement->bindValue(':uid', $player, SQLITE3_TEXT);
  30. $statement->bindValue(':id', $id, SQLITE3_TEXT);
  31. $statement->execute();
  32. return 0;
  33. }
  34. ?>