/** * Loads a list of objects for the specicifies parameters, returns an array of Object_Abstract elements * * @return array */ public function load() { $comments = array(); $commentsData = $this->db->fetchAll("SELECT id FROM plugin_ratingscomments_ratings" . $this->getCondition() . $this->getOrder() . $this->getOffsetLimit()); foreach ($commentsData as $commentData) { // return all comments as Type Commenting $comments[] = RatingsComments::getById($commentData["id"]); } $this->model->setComments($comments); return $comments; }
/** * Deletes all comments for the current target * * @return void */ public function deleteAllForTarget() { if ($this->model != null) { $targetId = $this->model->getTargetId(); if (!empty($targetId)) { try { $this->db->delete("plugin_ratingscomments_ratings", "targetId='" . $targetId . "'"); } catch (Exception $e) { logger::log(get_class($this) . ": Could not delete ratings for target id [" . $targetId . "]"); throw $e; } } } }
/** * * @param int $id */ public static function getById($id) { $comment = new RatingsComments(); $comment->getResource()->getById($id); return $comment; }
public function deleteComment($id) { $comment = RatingsComments::getById($id); $comment->delete(); }