From 2d9887993cc2c5dbbc22106c07906220bf33836f Mon Sep 17 00:00:00 2001 From: rvelices Date: Tue, 11 Feb 2014 21:47:44 +0000 Subject: arrayfromquery optimizations: move double if from inside loop to outside + use directly mysqli calls to avoid function call overhead for every row retrieved from db git-svn-id: http://piwigo.org/svn/trunk@27336 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/category_cats.inc.php | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'include/category_cats.inc.php') diff --git a/include/category_cats.inc.php b/include/category_cats.inc.php index bb048297f..839a86c8f 100644 --- a/include/category_cats.inc.php +++ b/include/category_cats.inc.php @@ -133,14 +133,13 @@ SELECT representative_picture_id if ($conf['display_fromto']) { - $dates_of_category = array(); if (count($category_ids) > 0) { $query = ' SELECT category_id, - MIN(date_creation) AS date_creation_min, - MAX(date_creation) AS date_creation_max + MIN(date_creation) AS `from`, + MAX(date_creation) AS `to` FROM '.IMAGE_CATEGORY_TABLE.' INNER JOIN '.IMAGES_TABLE.' ON image_id = id WHERE category_id IN ('.implode(',', $category_ids).') @@ -155,14 +154,7 @@ SELECT ).' GROUP BY category_id ;'; - $result = pwg_query($query); - while ($row = pwg_db_fetch_assoc($result)) - { - $dates_of_category[ $row['category_id'] ] = array( - 'from' => $row['date_creation_min'], - 'to' => $row['date_creation_max'], - ); - } + $dates_of_category = query2array($query, 'category_id'); } } -- cgit v1.2.3