delete_team.php 1013 B

12345678910111213141516171819202122232425262728293031323334
  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. */
  19. function action(){
  20. $player = filter_input(INPUT_POST, 'player');
  21. $id = filter_input(INPUT_POST, 'id');
  22. $statement = get_context()->get_db()->prepare('DELETE FROM team WHERE player = :player AND id = :id;');
  23. $statement->bindValue(':player', $player, SQLITE3_TEXT);
  24. $statement->bindValue(':id', $id, SQLITE3_TEXT);
  25. $statement->execute();
  26. $statement = get_context()->get_db()->prepare('DELETE FROM team_unit WHERE team = :id;');
  27. $statement->bindValue(':id', $id, SQLITE3_TEXT);
  28. $statement->execute();
  29. return 0;
  30. }
  31. ?>