delete_team.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  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. * player
  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, 'player');
  23. $id = filter_input(INPUT_POST, 'id');
  24. $statement = $db->prepare('DELETE FROM team WHERE player = :player AND id = :id;');
  25. $statement->bindValue(':player', $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(':id', $id, SQLITE3_TEXT);
  30. $statement->execute();
  31. return 0;
  32. }
  33. ?>