GROUP BY korrigiert

This commit is contained in:
Carsten Götzinger 2018-02-14 16:11:30 +01:00
parent c63c4dd127
commit 9cef234103

View File

@ -41,31 +41,31 @@ class RateItFrontend extends \Hybrid
* @var string * @var string
*/ */
protected $strPk = 'id'; protected $strPk = 'id';
/** /**
* Typ * Typ
* @var string * @var string
*/ */
protected $strType = 'hearts'; protected $strType = 'hearts';
/** /**
* Template * Template
* @var string * @var string
*/ */
protected $strTemplate = 'rateit_default'; protected $strTemplate = 'rateit_default';
/** /**
* Anzahl der Herzen/Sterne * Anzahl der Herzen/Sterne
* @var int * @var int
*/ */
protected $intStars = 5; protected $intStars = 5;
/** /**
* Textposition * Textposition
* @var string * @var string
*/ */
protected $strTextPosition = 'after'; protected $strTextPosition = 'after';
/** /**
* Initialize the controller * Initialize the controller
*/ */
@ -77,10 +77,10 @@ class RateItFrontend extends \Hybrid
elseif ($objElement instanceof \Model\Collection) { elseif ($objElement instanceof \Model\Collection) {
$this->strTable = $objElement->current()->getTable(); $this->strTable = $objElement->current()->getTable();
} }
$this->strKey = $this->strPk; $this->strKey = $this->strPk;
} }
$stars = intval($GLOBALS['TL_CONFIG']['rating_count']); $stars = intval($GLOBALS['TL_CONFIG']['rating_count']);
if ($stars > 0) { if ($stars > 0) {
$this->intStars = $stars; $this->intStars = $stars;
@ -110,7 +110,7 @@ class RateItFrontend extends \Hybrid
*/ */
protected function compile() { protected function compile() {
} }
public function getStarMessage($rating) { public function getStarMessage($rating) {
$this->loadLanguageFile('default'); $this->loadLanguageFile('default');
$stars = $this->percentToStars($rating['rating']); $stars = $this->percentToStars($rating['rating']);
@ -136,12 +136,12 @@ class RateItFrontend extends \Hybrid
public function loadRating($rkey, $typ) { public function loadRating($rkey, $typ) {
$SQL_GET_RATINGS = "SELECT i.rkey AS rkey, $SQL_GET_RATINGS = "SELECT i.rkey AS rkey,
i.title AS title, i.title AS title,
IFNULL(AVG(r.rating),0) AS rating, IFNULL(AVG(r.rating),0) AS rating,
COUNT( r.rating ) AS totalRatings COUNT( r.rating ) AS totalRatings
FROM tl_rateit_items i FROM tl_rateit_items i
LEFT OUTER JOIN tl_rateit_ratings r LEFT OUTER JOIN tl_rateit_ratings r
ON ( i.id = r.pid ) WHERE i.rkey = ? and typ=? and active='1' 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) $result = $this->Database->prepare($SQL_GET_RATINGS)
->execute($rkey, $typ) ->execute($rkey, $typ)
->fetchAssoc(); ->fetchAssoc();
@ -154,4 +154,4 @@ class RateItFrontend extends \Hybrid
} }
} }
?> ?>