From 9cef234103272c3bf87a3281914f42d6848cff29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carsten=20G=C3=B6tzinger?= Date: Wed, 14 Feb 2018 16:11:30 +0100 Subject: [PATCH] GROUP BY korrigiert --- .../contao/classes/RateItFrontend.php | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Resources/contao/classes/RateItFrontend.php b/src/Resources/contao/classes/RateItFrontend.php index 00ae9cf..f66462f 100644 --- a/src/Resources/contao/classes/RateItFrontend.php +++ b/src/Resources/contao/classes/RateItFrontend.php @@ -41,31 +41,31 @@ class RateItFrontend extends \Hybrid * @var string */ protected $strPk = 'id'; - + /** * Typ * @var string */ - protected $strType = 'hearts'; - + protected $strType = 'hearts'; + /** * Template * @var string */ - protected $strTemplate = 'rateit_default'; - + protected $strTemplate = 'rateit_default'; + /** * Anzahl der Herzen/Sterne * @var int */ protected $intStars = 5; - + /** * Textposition * @var string */ protected $strTextPosition = 'after'; - + /** * Initialize the controller */ @@ -77,10 +77,10 @@ class RateItFrontend extends \Hybrid elseif ($objElement instanceof \Model\Collection) { $this->strTable = $objElement->current()->getTable(); } - + $this->strKey = $this->strPk; } - + $stars = intval($GLOBALS['TL_CONFIG']['rating_count']); if ($stars > 0) { $this->intStars = $stars; @@ -110,7 +110,7 @@ class RateItFrontend extends \Hybrid */ protected function compile() { } - + public function getStarMessage($rating) { $this->loadLanguageFile('default'); $stars = $this->percentToStars($rating['rating']); @@ -136,12 +136,12 @@ class RateItFrontend extends \Hybrid public function loadRating($rkey, $typ) { $SQL_GET_RATINGS = "SELECT i.rkey AS rkey, i.title AS title, - IFNULL(AVG(r.rating),0) AS rating, + IFNULL(AVG(r.rating),0) AS rating, COUNT( r.rating ) AS totalRatings FROM tl_rateit_items i LEFT OUTER JOIN tl_rateit_ratings r ON ( i.id = r.pid ) WHERE i.rkey = ? and typ=? and active='1' - GROUP BY i.rkey;"; + GROUP BY i.rkey, i.title;"; $result = $this->Database->prepare($SQL_GET_RATINGS) ->execute($rkey, $typ) ->fetchAssoc(); @@ -154,4 +154,4 @@ class RateItFrontend extends \Hybrid } } -?> \ No newline at end of file +?>