Polls::delete PHP Method

delete() public method

public delete ( $id )
    public function delete($id)
    {
        if ($this->user->getClass() < User::CLASS_ADMIN) {
            throw new Exception(L::get("PERMISSION_DENIED"), 401);
        }
        $sth = $this->db->prepare("DELETE FROM polls WHERE id = ?");
        $sth->bindParam(1, $id, PDO::PARAM_INT);
        $sth->execute();
        $sth = $this->db->prepare("DELETE FROM pollanswers WHERE pollid = ?");
        $sth->bindParam(1, $id, PDO::PARAM_INT);
        $sth->execute();
    }

Usage Example

Example #1
0
     httpResponse($polls->vote($params[2], (int) $postdata["choise"]));
     break;
 case validateRoute('POST', 'polls'):
     $forum = new Forum($db, $user);
     $polls = new Polls($db, $user, $forum);
     $polls->create($postdata);
     httpResponse();
     break;
 case validateRoute('PATCH', 'polls/\\d+'):
     $polls = new Polls($db, $user);
     $polls->update($params[1], $postdata);
     httpResponse();
     break;
 case validateRoute('DELETE', 'polls/\\d+'):
     $polls = new Polls($db, $user);
     $polls->delete($params[1], $postdata);
     httpResponse();
     break;
 case validateRoute('GET', 'torrents'):
     $torrent = new Torrent($db, $user);
     list($torrents, $total) = $torrent->search($_GET["categories"], $_GET['section'], $_GET["index"], $_GET["limit"], $_GET["sort"], $_GET["order"], $_GET["searchText"], $_GET["hideOld"], $_GET["p2p"], $_GET["extendedSearch"], $_GET["watchview"]);
     if ($_GET["page"]) {
         $user->updateLastTorrentViewAccess($_GET["page"]);
     }
     httpResponse($torrents, $total);
     break;
 case validateRoute('GET', 'torrents/\\d+'):
     $torrent = new Torrent($db);
     $myTorrent = $torrent->get($params[1]);
     httpResponse($myTorrent);
     break;