rate_team.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. * File for the team score modification.
  4. *
  5. * Implements an action function to be called from the {@see Controller}.
  6. *
  7. * @category Action
  8. */
  9. /**
  10. * Sets the score for a team.
  11. *
  12. * Reads the POST parameters looking for the following KEYS:
  13. * uid
  14. * team
  15. * score
  16. * Validates the data and sets the score.
  17. *
  18. * @return int 0 on success, negative values on error.
  19. * @category Action
  20. * @global resource Database connection.
  21. */
  22. function action(){
  23. global $db;
  24. $player = filter_input(INPUT_GET, "uid");
  25. $team = filter_input(INPUT_GET, "team");
  26. $score = intval(filter_input(INPUT_GET, "score"));
  27. $statement = $db->prepare("
  28. UPDATE team
  29. SET score = :score
  30. WHERE
  31. uid = :uid AND
  32. id = :team;
  33. ");
  34. $statement->bindValue(":score", $score, SQLITE3_TEXT);
  35. $statement->bindValue(":uid", $player, SQLITE3_TEXT);
  36. $statement->bindValue(":team", $team, SQLITE3_TEXT);
  37. $statement->execute();
  38. return 0;
  39. }
  40. ?>