public function addVote($topic_id) { $sql = "UPDATE votes\n\t\t\t\tSET count = count + 1\n\t\t\t\tWHERE topic_id = :id "; $query = \vendor\Db::getInstance()->prepare($sql); $data = ['id' => $topic_id]; return $query->execute($data); }
public function delete($id) { $sql = "DELETE FROM topics WHERE id = :id"; $query = \vendor\Db::getInstance()->prepare($sql); $data = ['id' => $id]; return $query->execute($data); }
public function delete($id) { $sql = "DELETE FROM topics WHERE id = :id"; $query = \vendor\Db::getInstance()->prepare($sql); $data = ['id' => $id]; $result = $query->execute($data); if (!$result) { return false; } $sql = "DELETE FROM votes WHERE topic_id = :id"; $query = \vendor\Db::getInstance()->prepare($sql); return $query->execute($data); }