aboutsummaryrefslogtreecommitdiffstats
path: root/include/picture_rate.inc.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/picture_rate.inc.php')
-rw-r--r--include/picture_rate.inc.php12
1 files changed, 10 insertions, 2 deletions
diff --git a/include/picture_rate.inc.php b/include/picture_rate.inc.php
index 331cb41b0..f2410945b 100644
--- a/include/picture_rate.inc.php
+++ b/include/picture_rate.inc.php
@@ -32,14 +32,22 @@
if ($conf['rate'])
{
- $query = '
+ if ( NULL != $picture['current']['average_rate'] )
+ {
+ $query = '
SELECT COUNT(rate) AS count
, ROUND(AVG(rate),2) AS average
, ROUND(STD(rate),2) AS STD
FROM '.RATE_TABLE.'
WHERE element_id = '.$picture['current']['id'].'
;';
- $row = mysql_fetch_array(pwg_query($query));
+ $row = mysql_fetch_array(pwg_query($query));
+ }
+ else
+ { // avg rate null -> no rate -> no need to query db
+ $row = array( 'count'=>0, 'average'=>NULL, 'std'=>NULL );
+ }
+
if ($row['count'] == 0)
{
$value = l10n('no_rate');