id = $pid; $this->name = $pname; } public function getUri () { return "?page=".parent::PAGE_RATING_DETAIL."&id=$this->id"; } public function getEntryId () { return self::ALL_RATING_ID.":".$this->id; } public static function getCount() { $nRatings = parent::getDb ()->query('select count(*) from ratings')->fetchColumn(); $entry = new Entry (localize("ratings.title"), self::ALL_RATING_ID, str_format (localize("ratings", $nRatings), $nRatings), "text", array ( new LinkNavigation ("?page=".parent::PAGE_ALL_RATINGS))); return $entry; } public static function getAllRatings() { return self::getEntryArray (self::SQL_ALL_RATINGS, array ()); } public static function getEntryArray ($query, $params) { list (, $result) = parent::executeQuery ($query, self::RATING_COLUMNS, "", $params, -1); $entryArray = array(); while ($post = $result->fetchObject ()) { $ratingObj = new Rating ($post->id, $post->rating); $rating=$post->rating/2; $rating = str_format (localize("ratingword", $rating), $rating); array_push ($entryArray, new Entry ($rating, $ratingObj->getEntryId (), str_format (localize("bookword", $post->count), $post->count), "text", array ( new LinkNavigation ($ratingObj->getUri ())))); } return $entryArray; } public static function getRatingById ($ratingId) { $result = parent::getDb ()->prepare('select rating from ratings where id = ?'); $result->execute (array ($ratingId)); return new Author ($ratingId, $result->fetchColumn ()); } }