Changeset 637


Ignore:
Timestamp:
Dec 5, 2004, 11:02:36 PM (19 years ago)
Author:
plg
Message:

if all links between a category and elements have disappeared, no line is
returned by the update_category query but the update must be done with
nb_images = 0 and date_last = NULL

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/functions.php

    r635 r637  
    505505  WHERE category_id IN ('.implode(',', $cat_ids).')
    506506  GROUP BY category_id
    507 ';
     507;';
    508508  $result = pwg_query($query);
    509509  $datas = array();
     510  $query_ids = array();
    510511  while ( $row = mysql_fetch_array( $result ) )
    511512  {
     513    array_push($query_ids, $row['category_id']);
    512514    array_push($datas, array('id' => $row['category_id'],
    513515                             'date_last' => $row['date_last'],
    514516                             'nb_images' => $row['nb_images']));
    515517  }
     518  // if all links between a category and elements have disappeared, no line
     519  // is returned but the update must be done !
     520  foreach (array_diff($cat_ids, $query_ids) as $id)
     521  {
     522    array_push($datas, array('id' => $id, 'nb_images' => 0));
     523  }
     524 
    516525  $fields = array('primary' => array('id'),
    517526                  'update'  => array('date_last', 'nb_images'));
Note: See TracChangeset for help on using the changeset viewer.