rate_team.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. * player
  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. */
  21. function action(){
  22. $player = filter_input(INPUT_GET, "player");
  23. $team = filter_input(INPUT_GET, "team");
  24. $score = intval(filter_input(INPUT_GET, "score"));
  25. $statement = get_context()->get_db()->prepare("
  26. UPDATE team
  27. SET score = :score
  28. WHERE
  29. player = :player AND
  30. id = :team;
  31. ");
  32. $statement->bindValue(":score", $score, SQLITE3_TEXT);
  33. $statement->bindValue(":player", $player, SQLITE3_TEXT);
  34. $statement->bindValue(":team", $team, SQLITE3_TEXT);
  35. $statement->execute();
  36. return 0;
  37. }
  38. ?>