Changeset 610 for trunk/admin/update.php


Ignore:
Timestamp:
Nov 20, 2004, 6:23:42 PM (20 years ago)
Author:
plg
Message:
  • optimization : representative picture becomes mandatory for a non empty category. So, at each insertion in images table for a category, a new representative element is elected (by rand). This must be improved by not reelcting a random picture admin set an element as representative manually.
  • optimization : recent cats page only needs 2 queries instead of 3*N (N categories to display). The bad point is that it shows representative element of recent cat and not a random element among recently added.
  • optimization : empty cats page only needs 1 query per non empty sub category instead of... a lot. For each sub category, PhpWebGallery shows the representative element of a category chosen randomly in sub cats. Thus, get_non_empty_subcat_ids and get_first_non_empty_cat_id becomes obsolete.
  • new function get_cat_display_name_cache to show category names with a caching for all gallery categories names. This function, to the contrary of get_cat_display_name shows names in the correct order...
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/update.php

    r606 r610  
    513513  (category_id,image_id) VALUES
    514514  '.implode(',', $ids).'
     515;';
     516    pwg_query($query);
     517
     518    // set a new representative element for this category
     519    $query = '
     520SELECT image_id
     521  FROM '.IMAGE_CATEGORY_TABLE.'
     522  WHERE category_id = '.$category_id.'
     523  ORDER BY RAND()
     524  LIMIT 0,1
     525;';
     526    list($representative) = mysql_fetch_array(pwg_query($query));
     527    $query = '
     528UPDATE '.CATEGORIES_TABLE.'
     529  SET representative_picture_id = '.$representative.'
     530  WHERE id = '.$category_id.'
    515531;';
    516532    pwg_query($query);
Note: See TracChangeset for help on using the changeset viewer.