aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2008-04-25 23:38:04 +0000
committerrvelices <rv-github@modusoptimus.com>2008-04-25 23:38:04 +0000
commit10dbfea6f633107a90d84d07bba70e807d172eeb (patch)
treee2fbd06e6c20b923f75fc589e814e4bfafb79a8c /include
parent94aa1b52822c599229db9933c4d5678484afe467 (diff)
- less mysql queries on picture page (under some circumstances)
git-svn-id: http://piwigo.org/svn/trunk@2309 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--include/picture_rate.inc.php11
1 files changed, 9 insertions, 2 deletions
diff --git a/include/picture_rate.inc.php b/include/picture_rate.inc.php
index b5fc884d9..aa1071452 100644
--- a/include/picture_rate.inc.php
+++ b/include/picture_rate.inc.php
@@ -28,14 +28,21 @@
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 );
+ }
$template->assign('rate_summary', $row);
$user_rate = null;