public function vote($pollId, $choise)
{
if ($choise < 0 || $choise > 19 && $choise != 255) {
throw new Exception(L::get("POLLS_ILLEGAL_CHOISE"), 412);
}
$sth = $this->db->prepare("SELECT COUNT(*) FROM `pollanswers` WHERE `userid` = ? AND `pollid` = ?");
$sth->bindValue(1, $this->user->getId(), PDO::PARAM_INT);
$sth->bindParam(2, $pollId, PDO::PARAM_INT);
$sth->execute();
$res = $sth->fetch();
if ($res[0] == 1) {
throw new Exception(L::get("POLLS_ALREADY_VOTED"), 409);
}
$sth = $this->db->prepare("INSERT INTO pollanswers(pollid, userid, selection, class, alder) VALUES(?, ?, ?, ?, ?)");
$sth->bindParam(1, $pollId, PDO::PARAM_INT);
$sth->bindValue(2, $this->user->getId(), PDO::PARAM_INT);
$sth->bindParam(3, $choise, PDO::PARAM_INT);
$sth->bindValue(4, $this->user->getClass(), PDO::PARAM_INT);
$sth->bindValue(5, $this->user->getAge(), PDO::PARAM_INT);
$sth->execute();
}